├── .gitattributes ├── src ├── main │ ├── webapp │ │ ├── upload │ │ ├── favicon.ico │ │ ├── assets │ │ │ ├── img │ │ │ │ ├── clear.png │ │ │ │ └── loading.gif │ │ │ ├── avatars │ │ │ │ ├── user.jpg │ │ │ │ ├── avatar.png │ │ │ │ ├── avatar1.png │ │ │ │ ├── avatar2.png │ │ │ │ ├── avatar3.png │ │ │ │ ├── avatar4.png │ │ │ │ ├── avatar5.png │ │ │ │ └── profile-pic.jpg │ │ │ ├── css │ │ │ │ ├── img │ │ │ │ │ ├── hue.png │ │ │ │ │ ├── alpha.png │ │ │ │ │ └── saturation.png │ │ │ │ ├── select2.png │ │ │ │ ├── select2x2.png │ │ │ │ ├── chosen-sprite.png │ │ │ │ ├── images │ │ │ │ │ ├── border.png │ │ │ │ │ ├── controls.png │ │ │ │ │ ├── loading.gif │ │ │ │ │ ├── overlay.png │ │ │ │ │ ├── pattern.jpg │ │ │ │ │ ├── meteorshower2.jpg │ │ │ │ │ ├── loading_background.png │ │ │ │ │ └── animated-overlay.gif │ │ │ │ ├── select2-spinner.gif │ │ │ │ ├── chosen-sprite@2x.png │ │ │ │ ├── google-fonts.css │ │ │ │ └── bootstrap-duallistbox.min.css │ │ │ ├── fonts │ │ │ │ ├── OpenSans.woff │ │ │ │ ├── OpenSans-Light.woff │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ └── glyphicons-halflings-regular.woff │ │ │ ├── images │ │ │ │ ├── spritemap.png │ │ │ │ ├── spritemap@2x.png │ │ │ │ ├── gallery │ │ │ │ │ ├── thumb-1.jpg │ │ │ │ │ ├── thumb-2.jpg │ │ │ │ │ ├── thumb-3.jpg │ │ │ │ │ └── thumb-4.jpg │ │ │ │ ├── gritter.png │ │ │ │ ├── ie-spacer.gif │ │ │ │ └── gritter-light.png │ │ │ └── js │ │ │ │ ├── jquery.ui.touch-punch.min.js │ │ │ │ └── flot │ │ │ │ └── jquery.flot.resize.min.js │ │ ├── ztree │ │ │ └── img │ │ │ │ ├── diy │ │ │ │ ├── 2.png │ │ │ │ ├── 3.png │ │ │ │ ├── 4.png │ │ │ │ ├── 5.png │ │ │ │ ├── 6.png │ │ │ │ ├── 7.png │ │ │ │ ├── 8.png │ │ │ │ ├── 9.png │ │ │ │ ├── 1_close.png │ │ │ │ └── 1_open.png │ │ │ │ ├── line_conn.gif │ │ │ │ ├── loading.gif │ │ │ │ ├── zTreeStandard.gif │ │ │ │ └── zTreeStandard.png │ │ ├── index.jsp │ │ ├── bootstrap3.3.5 │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ └── js │ │ │ │ └── npm.js │ │ ├── mvc-views │ │ │ └── success.jsp │ │ ├── css │ │ │ ├── group_col.gif │ │ │ └── signin.css │ │ └── js │ │ │ └── ie10-viewport-bug-workaround.js │ ├── resources │ │ ├── properties │ │ │ ├── config.properties │ │ │ └── default.properties │ │ ├── mapper │ │ │ ├── SysToolMapper.xml │ │ │ ├── TestMapper.xml │ │ │ ├── ShortUrlMapper.xml │ │ │ ├── FileInfoMapper.xml │ │ │ ├── ProductMapper.xml │ │ │ ├── SysRoleUserMapper.xml │ │ │ ├── SysRoleAclMapper.xml │ │ │ ├── SysRoleMapper.xml │ │ │ ├── ConfigurationMapper.xml │ │ │ ├── ArticleMapper.xml │ │ │ └── ScheduleExecuteResultMapper.xml │ │ ├── quartz.properties │ │ ├── spring-redis.xml │ │ ├── spring-rabbit.xml │ │ └── mybatis-config.xml │ ├── resource.dev │ │ ├── redis.properties │ │ ├── rabbit.properties │ │ └── jdbc.properties │ ├── resource.prod │ │ ├── redis.properties │ │ ├── rabbit.properties │ │ └── jdbc.properties │ └── java │ │ └── com │ │ └── app │ │ └── mvc │ │ ├── acl │ │ ├── dao │ │ │ ├── package-info.java │ │ │ ├── SysRoleDao.java │ │ │ ├── SysRoleUserDao.java │ │ │ ├── SysRoleAclDao.java │ │ │ ├── SysToolDao.java │ │ │ ├── SysLogDao.java │ │ │ ├── SysDeptDao.java │ │ │ ├── SysAclDao.java │ │ │ ├── SysAclModuleDao.java │ │ │ └── SysUserDao.java │ │ ├── dto │ │ │ ├── package-info.java │ │ │ ├── CookieUser.java │ │ │ ├── AclDto.java │ │ │ ├── LoginUser.java │ │ │ ├── AclModuleLevelDto.java │ │ │ ├── DeptLevelDto.java │ │ │ └── LogSearchDto.java │ │ ├── util │ │ │ ├── package-info.java │ │ │ ├── LevelUtil.java │ │ │ └── RequestHolder.java │ │ ├── vo │ │ │ ├── package-info.java │ │ │ ├── DeptPara.java │ │ │ ├── AclModulePara.java │ │ │ ├── RolePara.java │ │ │ ├── LogPara.java │ │ │ ├── AclPara.java │ │ │ └── UserPara.java │ │ ├── config │ │ │ ├── package-info.java │ │ │ └── LogTypeServiceConfig.java │ │ ├── domain │ │ │ ├── package-info.java │ │ │ ├── SysBase.java │ │ │ ├── SysRoleUser.java │ │ │ ├── SysRoleAcl.java │ │ │ ├── SysLog.java │ │ │ ├── SysDept.java │ │ │ ├── SysRole.java │ │ │ ├── SysAclModule.java │ │ │ ├── SysAcl.java │ │ │ └── SysUser.java │ │ ├── enums │ │ │ ├── package-info.java │ │ │ ├── AclType.java │ │ │ ├── Status.java │ │ │ ├── RoleType.java │ │ │ ├── CacheKeyConstants.java │ │ │ └── LogType.java │ │ ├── filter │ │ │ └── package-info.java │ │ ├── convert │ │ │ ├── package-info.java │ │ │ ├── DeptConvert.java │ │ │ ├── AclModuleConvert.java │ │ │ ├── AclConvert.java │ │ │ ├── RoleConvert.java │ │ │ ├── UserConvert.java │ │ │ ├── LogConvert.java │ │ │ └── BaseConvert.java │ │ ├── service │ │ │ ├── package-info.java │ │ │ ├── SysService.java │ │ │ └── SysToolService.java │ │ ├── servlet │ │ │ ├── package-info.java │ │ │ └── LogoutServlet.java │ │ └── controller │ │ │ ├── package-info.java │ │ │ └── SysToolController.java │ │ ├── common │ │ ├── package-info.java │ │ ├── SelfAware.java │ │ ├── ThreadHelper.java │ │ ├── BaseService.java │ │ ├── InitData.java │ │ ├── DBRepository.java │ │ ├── SpringContextLoadListener.java │ │ ├── SpringHelper.java │ │ ├── ApplicationContextHelper.java │ │ ├── HttpInterceptor.java │ │ ├── SpringExceptionResolver.java │ │ ├── ServiceDegarding.java │ │ ├── ThreadPool.java │ │ └── LogEmailFilter.java │ │ ├── business │ │ ├── bo │ │ │ ├── package-info.java │ │ │ └── FileUploadBo.java │ │ ├── domain │ │ │ ├── package-info.java │ │ │ ├── Test.java │ │ │ ├── Product.java │ │ │ ├── FileInfo.java │ │ │ ├── Article.java │ │ │ └── Investment.java │ │ ├── service │ │ │ ├── package-info.java │ │ │ ├── TestDataSourceService.java │ │ │ ├── ProductService.java │ │ │ └── TestService.java │ │ ├── controller │ │ │ ├── package-info.java │ │ │ ├── NavigatorController.java │ │ │ ├── CommonController.java │ │ │ ├── InvestmentController.java │ │ │ ├── ProductController.java │ │ │ └── ArticleController.java │ │ ├── dao │ │ │ ├── TestDao.java │ │ │ ├── FileInfoDao.java │ │ │ ├── ProductDao.java │ │ │ ├── InvestmentDao.java │ │ │ └── ArticleDao.java │ │ ├── enums │ │ │ ├── Sex.java │ │ │ └── BusinessModelType.java │ │ └── vo │ │ │ ├── ProductPara.java │ │ │ ├── ArticlePara.java │ │ │ └── InvestmentPara.java │ │ ├── util │ │ ├── package-info.java │ │ ├── ByteUtil.java │ │ ├── SerializableUtil.java │ │ ├── TimePointUtil.java │ │ ├── FileUtil.java │ │ ├── MD5Util.java │ │ ├── PasswordUtil.java │ │ ├── Base64Util.java │ │ ├── NasdaqParser.java │ │ ├── HashUtil.java │ │ ├── PropertiesUtil.java │ │ └── MailUtil.java │ │ ├── beans │ │ ├── package-info.java │ │ ├── PageResult.java │ │ ├── Mail.java │ │ ├── PageQuery.java │ │ └── JsonData.java │ │ ├── config │ │ ├── package-info.java │ │ ├── ConfigurationParam.java │ │ ├── ConfigurationDao.java │ │ ├── Configuration.java │ │ ├── ConfigurationService.java │ │ └── ConfigurationController.java │ │ ├── exception │ │ ├── package-info.java │ │ ├── ParaException.java │ │ └── NotFoundException.java │ │ ├── http │ │ ├── package-info.java │ │ ├── ext │ │ │ └── AuthSSLInitializationError.java │ │ ├── CallbackAdaptor.java │ │ ├── HttpCallback.java │ │ └── HttpClients.java │ │ ├── captcha │ │ ├── package-info.java │ │ ├── CaptchaCode.java │ │ ├── CaptchaCodeDao.java │ │ ├── CaptchaController.java │ │ └── CaptchaImgFont.java │ │ ├── shortUrl │ │ ├── ShortUrlDao.java │ │ ├── ShortUrl.java │ │ ├── ShortUrlController.java │ │ └── ShortUrlService.java │ │ ├── datasource │ │ ├── DataSources.java │ │ ├── RoutingDataSource.java │ │ ├── AspectOrder.java │ │ ├── DynamicDataSource.java │ │ └── DataSourceKeyHolder.java │ │ ├── schedule │ │ ├── ScheduleJobStatus.java │ │ ├── ScheduleExecuteStatus.java │ │ ├── ScheduleJobSettingParam.java │ │ ├── ScheduleExecuteResultDto.java │ │ ├── ScheduleExecuteResult.java │ │ ├── ScheduleJobSettingDao.java │ │ ├── ScheduledJobSetting.java │ │ ├── ScheduleJobDto.java │ │ ├── ScheduleExecuteResultDao.java │ │ ├── jobs │ │ │ └── ExampleScheduledJob.java │ │ ├── AbstractScheduleJob.java │ │ └── AutoRegisterScheduleJob.java │ │ ├── rabbitmq │ │ ├── MessageConsumeService.java │ │ └── MessageProduceService.java │ │ ├── test │ │ ├── TestTimezone.java │ │ ├── TestQuartz.java │ │ ├── TestThreadGroup.java │ │ ├── TestCallable.java │ │ └── TestAsyncTimeout.java │ │ ├── proxy │ │ ├── UrlConnectionChecker.java │ │ └── checker │ │ │ └── DefaultUrlConnectionChecker.java │ │ └── redis │ │ └── RedisPool.java └── test │ └── java │ └── com │ └── app │ └── mvc │ └── dao │ ├── BaseJunitTest.java │ └── ShortUrlDaoTest.java ├── qrcode_258.jpg ├── backup.sh ├── .gitignore ├── sql └── init_log.sql └── Untitled Diagram.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-language=Java -------------------------------------------------------------------------------- /src/main/webapp/upload: -------------------------------------------------------------------------------- 1 | /Users/jimin/upload -------------------------------------------------------------------------------- /src/main/resources/properties/config.properties: -------------------------------------------------------------------------------- 1 | isProd=true -------------------------------------------------------------------------------- /src/main/resources/properties/default.properties: -------------------------------------------------------------------------------- 1 | test=test123 -------------------------------------------------------------------------------- /qrcode_258.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/qrcode_258.jpg -------------------------------------------------------------------------------- /src/main/resource.dev/redis.properties: -------------------------------------------------------------------------------- 1 | redis.ip = 127.0.0.1 2 | redis.port = 6379 3 | redis.timeout = 3000 -------------------------------------------------------------------------------- /src/main/webapp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/favicon.ico -------------------------------------------------------------------------------- /src/main/resource.prod/redis.properties: -------------------------------------------------------------------------------- 1 | redis.ip = 127.0.0.1 2 | redis.port = 6379 3 | redis.timeout = 3000 -------------------------------------------------------------------------------- /src/main/webapp/assets/img/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/img/clear.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/2.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/3.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/4.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/5.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/6.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/7.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/8.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/9.png -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.dao; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.dto; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.util; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.vo; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.common; -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/user.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/user.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/css/img/hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/img/hue.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/select2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/select2.png -------------------------------------------------------------------------------- /src/main/webapp/assets/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/img/loading.gif -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/line_conn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/line_conn.gif -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/loading.gif -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.config; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.domain; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.enums; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.filter; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/bo/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/3/7. 3 | */ 4 | package com.app.mvc.business.bo; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 通用的工具 3 | * Created by jimin on 16/3/7. 4 | */ 5 | package com.app.mvc.util; -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/img/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/img/alpha.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/select2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/select2x2.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/1_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/1_close.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/diy/1_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/diy/1_open.png -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.convert; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/service/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.service; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/servlet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.servlet; -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar1.png -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar2.png -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar3.png -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar4.png -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/avatar5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/avatar5.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/chosen-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/chosen-sprite.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/border.png -------------------------------------------------------------------------------- /src/main/webapp/assets/fonts/OpenSans.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/fonts/OpenSans.woff -------------------------------------------------------------------------------- /src/main/webapp/assets/images/spritemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/spritemap.png -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/zTreeStandard.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/zTreeStandard.gif -------------------------------------------------------------------------------- /src/main/webapp/ztree/img/zTreeStandard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/ztree/img/zTreeStandard.png -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/controller/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/2/11. 3 | */ 4 | package com.app.mvc.acl.controller; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/beans/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 定义系统共用的一些类 3 | * Created by jimin on 16/2/11. 4 | */ 5 | package com.app.mvc.beans; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/3/7. 3 | */ 4 | package com.app.mvc.business.domain; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/service/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/3/7. 3 | */ 4 | package com.app.mvc.business.service; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 系统配置读取与更新 3 | * Created by jimin on 16/2/11. 4 | */ 5 | package com.app.mvc.config; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 异常封装 3 | * Created by jimin on 16/3/7. 4 | */ 5 | package com.app.mvc.exception; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/http/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * httpclient 封装 3 | * Created by jimin on 16/3/10. 4 | */ 5 | package com.app.mvc.http; -------------------------------------------------------------------------------- /src/main/webapp/assets/avatars/profile-pic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/avatars/profile-pic.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/controls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/controls.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/loading.gif -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/overlay.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/pattern.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/css/img/saturation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/img/saturation.png -------------------------------------------------------------------------------- /src/main/webapp/assets/css/select2-spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/select2-spinner.gif -------------------------------------------------------------------------------- /src/main/webapp/assets/images/spritemap@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/spritemap@2x.png -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/captcha/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 验证码生成及校验相关 3 | * Created by jimin on 16/2/11. 4 | */ 5 | package com.app.mvc.captcha; -------------------------------------------------------------------------------- /src/main/webapp/assets/css/chosen-sprite@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/chosen-sprite@2x.png -------------------------------------------------------------------------------- /src/main/webapp/assets/fonts/OpenSans-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/fonts/OpenSans-Light.woff -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gallery/thumb-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/gallery/thumb-1.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gallery/thumb-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/gallery/thumb-2.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gallery/thumb-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/gallery/thumb-3.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gallery/thumb-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/images/gallery/thumb-4.jpg -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jimin on 16/3/7. 3 | */ 4 | package com.app.mvc.business.controller; -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/meteorshower2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/meteorshower2.jpg -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/loading_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/css/images/loading_background.png -------------------------------------------------------------------------------- /src/main/webapp/assets/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/webapp/assets/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/webapp/assets/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/assets/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/resource.dev/rabbit.properties: -------------------------------------------------------------------------------- 1 | rabbit.host = 127.0.0.1 2 | rabbit.port = 5672 3 | rabbit.username = jimin 4 | rabbit.password = jimin 5 | rabbit.vhost = /test -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" %> 2 | 5 | -------------------------------------------------------------------------------- /src/main/resource.prod/rabbit.properties: -------------------------------------------------------------------------------- 1 | rabbit.host = 127.0.0.1 2 | rabbit.port = 5672 3 | rabbit.username = test 4 | rabbit.password = test 5 | rabbit.vhost = /test 6 | -------------------------------------------------------------------------------- /src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kanwangzjm/funiture/HEAD/src/main/webapp/bootstrap3.3.5/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/main/webapp/mvc-views/success.jsp: -------------------------------------------------------------------------------- 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 | 3 | 4 | 5 | 6 | 7 | Success 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gritter.png: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to nginx! 4 | 5 | 6 |

Welcome to nginx!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/webapp/assets/images/ie-spacer.gif: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to nginx! 4 | 5 | 6 |

Welcome to nginx!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/webapp/assets/images/gritter-light.png: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to nginx! 4 | 5 | 6 |

Welcome to nginx!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/webapp/assets/css/images/animated-overlay.gif: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to nginx! 4 | 5 | 6 |

Welcome to nginx!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/SelfAware.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | /** 4 | * Created by jimin on 16/03/22. 5 | */ 6 | public interface SelfAware { 7 | 8 | /** 9 | * spring上下文bean自感接口 10 | */ 11 | T self(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/service/SysService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.service; 2 | 3 | /** 4 | * 定义权限相关service都要处理的方法 5 | * Created by jimin on 16/1/24. 6 | */ 7 | 8 | public interface SysService { 9 | 10 | void recover(int targetId, Object o); 11 | } 12 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | Redis: http://redis.cn/commands.html /usr/local/bin/redis-server /usr/local/bin/redis-cli Zookeeper: zkServer start zkServer stop Rabbitmq: sudo rabbitmq-server rabbitmqctl list_queues 管理台: http://localhost:15672/ find . -name "*.java" | xargs perl -pi -e 's/\r\n|\n|\r/\n/g' -------------------------------------------------------------------------------- /src/main/resources/mapper/SysToolMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/dao/TestDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.dao; 2 | 3 | import com.app.mvc.business.domain.Test; 4 | import com.app.mvc.common.DBRepository; 5 | 6 | /** 7 | * Created by jimin on 16/3/22. 8 | */ 9 | @DBRepository 10 | public interface TestDao { 11 | 12 | void save(Test test); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/enums/Sex.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/3/7. 7 | */ 8 | @Getter 9 | public enum Sex { 10 | 11 | Male("M"), 12 | Female("F"); 13 | 14 | private String flag; 15 | 16 | Sex(String flag) { 17 | this.flag = flag; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/shortUrl/ShortUrlDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.shortUrl; 2 | 3 | import com.app.mvc.common.DBRepository; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * Created by jimin on 16/4/7. 8 | */ 9 | @DBRepository 10 | public interface ShortUrlDao { 11 | 12 | void save(ShortUrl shortUrl); 13 | 14 | ShortUrl findByNewUrl(@Param("url") String url); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/webapp/assets/css/google-fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Open Sans'; 3 | font-style: normal; 4 | font-weight: 300; 5 | src: local('Open Sans Light'), local('OpenSans-Light'), url(../fonts/OpenSans-Light.woff) format('woff'); 6 | } 7 | @font-face { 8 | font-family: 'Open Sans'; 9 | font-style: normal; 10 | font-weight: 400; 11 | src: local('Open Sans'), local('OpenSans'), url(../fonts/OpenSans.woff) format('woff'); 12 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/Test.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | /** 10 | * Created by jimin on 16/3/22. 11 | */ 12 | @Getter 13 | @Setter 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class Test { 18 | 19 | String text = ""; 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # kdiff3 ignore 2 | *.orig 3 | 4 | # maven ignore 5 | target/ 6 | 7 | # eclipse ignore 8 | .settings/ 9 | .project 10 | .classpath 11 | 12 | # idea ignore 13 | .idea/ 14 | *.ipr 15 | *.iml 16 | *.iws 17 | 18 | # temp ignore 19 | *.log 20 | *.cache 21 | *.diff 22 | *.patch 23 | *.tmp 24 | 25 | # system ignore 26 | /.idea 27 | .DS_Store 28 | Thumbs.db 29 | 30 | # package ignore (optional) 31 | # *.jar 32 | # *.war 33 | # *.zip 34 | # *.tar 35 | # *.tar.gz -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/datasource/DataSources.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.datasource; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/3/21. 7 | */ 8 | @Getter 9 | public enum DataSources { 10 | MASTER("db-master"), 11 | LOG("db-log"); 12 | 13 | private String key; 14 | 15 | DataSources(String key) { 16 | this.key = key; 17 | } 18 | 19 | public String key() { 20 | return key; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/enums/BusinessModelType.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/3/8. 7 | */ 8 | @Getter 9 | public enum BusinessModelType { 10 | SELF_SUPPORT("自营"), 11 | PARTNER_SHIP("合伙"), 12 | FAMILY("家族"), 13 | OTHER("其他"); 14 | 15 | private String desc; 16 | 17 | BusinessModelType(String desc) { 18 | this.desc = desc; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/AclType.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/1/16. 7 | */ 8 | @Getter 9 | public enum AclType { 10 | 11 | MENU(0, "菜单"), 12 | BUTTON(1, "按钮"), 13 | OTHER(2, "其他"); 14 | 15 | private int code; 16 | private String desc; 17 | 18 | AclType(int code, String desc) { 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/Status.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/1/16. 7 | */ 8 | @Getter 9 | public enum Status { 10 | 11 | AVAILABLE(1, "有效"), 12 | NOT_AVAILABLE(0, "无效"), 13 | DELETED(2, "删除"); 14 | 15 | private int code; 16 | private String desc; 17 | 18 | Status(int code, String desc) { 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/mapper/TestMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO test(text, create_time) 10 | VALUES 11 | (#{text}, now()) 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/ThreadHelper.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * Created by jimin on 16/6/22. 7 | */ 8 | @Slf4j 9 | public class ThreadHelper { 10 | 11 | public static void safeSleep(long millseconds) { 12 | try { 13 | Thread.currentThread().sleep(millseconds); 14 | } catch (Throwable t) { 15 | log.error("thread sleep exception", t); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/RoleType.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/1/16. 7 | */ 8 | @Getter 9 | public enum RoleType { 10 | 11 | ADMIN(0, "管理员角色"), 12 | SUPPLIER(1, "供应商角色"), 13 | OTHER(2, "备用角色"); 14 | 15 | private int code; 16 | private String desc; 17 | 18 | RoleType(int code, String desc) { 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/vo/ProductPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by jimin on 16/3/7. 10 | */ 11 | @Getter 12 | @Setter 13 | public class ProductPara { 14 | 15 | private Integer id; 16 | 17 | @NotNull(message = "标题不可以为空") 18 | private String title; 19 | 20 | @NotNull(message = "产品图片不可以为空") 21 | private String image; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleJobStatus.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/5/8. 7 | */ 8 | @Getter 9 | public enum ScheduleJobStatus { 10 | 11 | INIT(-1, "未开始过"), 12 | STARTED(1, "运行中"), 13 | STOPPED(0, "暂停"); 14 | 15 | private int code; 16 | private String desc; 17 | 18 | ScheduleJobStatus(int code, String desc) { 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/beans/PageResult.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.beans; 2 | 3 | import com.google.common.collect.Lists; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by jimin on 15/11/4. 13 | */ 14 | @Getter 15 | @Setter 16 | @ToString 17 | @Builder 18 | public class PageResult { 19 | 20 | private List data = Lists.newArrayList(); 21 | 22 | private int total = 0; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/dao/FileInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.dao; 2 | 3 | import com.app.mvc.business.domain.FileInfo; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | /** 8 | * Created by jimin on 15/11/29. 9 | */ 10 | @DBRepository 11 | public interface FileInfoDao { 12 | 13 | FileInfo findByMD5(@Param("md5") String md5); 14 | 15 | FileInfo findById(@Param("id") int id); 16 | 17 | void insert(FileInfo fileInfo); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | /** 4 | * Service的基类,实现SelfAware接口。 5 | * 可以通过self()方法拿到spring容器中的service实例,从而拥有增强特性。 6 | *

7 | * Created by jimin on 16/03/22. 8 | */ 9 | public abstract class BaseService implements SelfAware { 10 | 11 | private T self; 12 | 13 | @Override 14 | public T self() { 15 | if (self == null) 16 | self = (T) SpringHelper.popBean(getClass()); 17 | return self; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/ConfigurationParam.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.config; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | 8 | /** 9 | * Created by jimin on 15/11/7. 10 | */ 11 | @Getter 12 | @Setter 13 | @ToString 14 | public class ConfigurationParam { 15 | 16 | @NotBlank(message = "key不允许为空") 17 | private String k; 18 | 19 | private String v; 20 | 21 | private String comment; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resource.dev/jdbc.properties: -------------------------------------------------------------------------------- 1 | master.jdbc.driverClassName = com.mysql.jdbc.Driver 2 | master.jdbc.url = jdbc:mysql://localhost:3306/furniture?useUnicode=true&characterEncoding=UTF-8 3 | master.jdbc.username = root 4 | master.jdbc.password = 466420182 5 | 6 | log.jdbc.driverClassName = com.mysql.jdbc.Driver 7 | log.jdbc.url = jdbc:mysql://localhost:3306/log?useUnicode=true&characterEncoding=UTF-8 8 | log.jdbc.username = root 9 | log.jdbc.password = 466420182 -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/rabbitmq/MessageConsumeService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.rabbitmq; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.amqp.core.Message; 5 | import org.springframework.amqp.core.MessageListener; 6 | 7 | /** 8 | * Created by jimin on 16/3/11. 9 | */ 10 | @Slf4j 11 | public class MessageConsumeService implements MessageListener { 12 | 13 | @Override 14 | public void onMessage(Message message) { 15 | log.info(new String(message.getBody())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleExecuteStatus.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * Created by jimin on 16/5/9. 7 | */ 8 | @Getter 9 | public enum ScheduleExecuteStatus { 10 | RUNNING(0, "正在运行"), 11 | FINISHED(1, "已经完成"), 12 | EXCEPTION(2, "出现异常结束"); 13 | 14 | private int code; 15 | private String desc; 16 | 17 | ScheduleExecuteStatus(int code, String desc) { 18 | this.code = code; 19 | this.desc = desc; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/test/TestTimezone.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.test; 2 | 3 | import java.util.TimeZone; 4 | 5 | /** 6 | * Created by jimin on 16/8/14. 7 | */ 8 | public class TestTimezone { 9 | 10 | public static void main(String[] args) throws Exception { 11 | String[] s = TimeZone.getAvailableIDs(); 12 | for(String timezoneId : s) { 13 | TimeZone timeZone = TimeZone.getTimeZone(timezoneId); 14 | System.out.println(timezoneId + "\t" + timeZone.getDisplayName()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/InitData.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.captcha.CaptchaImgFont; 4 | import com.app.mvc.config.GlobalConfig; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | /** 8 | * Created by jimin on 15/11/21. 9 | */ 10 | @Slf4j 11 | public class InitData { 12 | 13 | public static void start() { 14 | 15 | log.info("init data start"); 16 | 17 | GlobalConfig.loadAllConfig(); 18 | CaptchaImgFont.initImgFont(); 19 | 20 | log.info("init data finish"); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleJobSettingParam.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | import javax.validation.constraints.NotNull; 8 | 9 | /** 10 | * Created by jimin on 16/5/8. 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | public class ScheduleJobSettingParam { 16 | 17 | @NotNull(message = "id不可以为空") 18 | private Integer id; 19 | 20 | private String cron; 21 | 22 | @NotNull(message = "状态不可以为空") 23 | private Integer status; 24 | } 25 | -------------------------------------------------------------------------------- /src/main/webapp/bootstrap3.3.5/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/vo/ArticlePara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by jimin on 16/3/8. 10 | */ 11 | @Getter 12 | @Setter 13 | public class ArticlePara { 14 | 15 | private Integer id; 16 | /** 17 | * 内容 18 | */ 19 | @NotNull(message = "内容不可以为空") 20 | private String content; 21 | /** 22 | * 标题 23 | */ 24 | @NotNull(message = "标题不可以为空") 25 | private String title; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/NavigatorController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * Created by jimin on 16/3/27. 9 | */ 10 | @Controller 11 | @RequestMapping("/admin") 12 | public class NavigatorController { 13 | 14 | @RequestMapping("/page.do") 15 | public ModelAndView toAdmin() { 16 | return new ModelAndView("admin"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/datasource/RoutingDataSource.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.datasource; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 可以动态切换至指定的数据源 11 | * Created by jimin on 16/03/22. 12 | */ 13 | @Target({ ElementType.METHOD }) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | public @interface RoutingDataSource { 17 | DataSources value() default DataSources.MASTER; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/CookieUser.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | /** 10 | * Created by jimin on 16/2/10. 11 | */ 12 | @Getter 13 | @Setter 14 | @Builder 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class CookieUser { 18 | 19 | private int userId; 20 | 21 | private String username; 22 | 23 | private long lastLogin; 24 | 25 | private String ip; 26 | 27 | private String mac; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/DBRepository.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * Created by jimin on 15/11/3. 13 | */ 14 | @Target({ ElementType.TYPE }) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Documented 17 | @Component 18 | public @interface DBRepository { 19 | 20 | String value() default ""; 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/com/app/mvc/dao/BaseJunitTest.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.dao; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; 6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 7 | 8 | /** 9 | * Created by jimin on 16/1/24. 10 | */ 11 | @RunWith(SpringJUnit4ClassRunner.class) 12 | @ContextConfiguration(locations = { "classpath:applicationContext.xml" }) 13 | public class BaseJunitTest extends AbstractJUnit4SpringContextTests { 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /sql/init_log.sql: -------------------------------------------------------------------------------- 1 | SET NAMES utf8; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for `test` -- ---------------------------- DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `text` text NOT NULL, `create_time` datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of `test` -- ---------------------------- BEGIN; INSERT INTO `test` VALUES ('1', '123123', '2016-03-22 01:28:21'), ('2', '123123', '2016-03-22 01:29:55'); COMMIT; SET FOREIGN_KEY_CHECKS = 1; -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/dao/ProductDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.dao; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import com.app.mvc.business.domain.Product; 5 | import com.app.mvc.common.DBRepository; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jimin on 15/11/4. 12 | */ 13 | @DBRepository 14 | public interface ProductDao { 15 | 16 | List getValidProductList(PageQuery pageQuery); 17 | 18 | int countValid(); 19 | 20 | void save(Product product); 21 | 22 | void invalid(@Param("id") int id); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/Product.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | /** 11 | * Created by jimin on 15/11/4. 12 | */ 13 | @ToString 14 | @Getter 15 | @Setter 16 | @Builder 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | public class Product { 20 | 21 | private Integer id; 22 | 23 | private String title; 24 | 25 | private String image; 26 | 27 | private int status; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/http/ext/AuthSSLInitializationError.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.http.ext; 2 | 3 | /** 4 | * Created by jimin on 16/03/10. 5 | */ 6 | public class AuthSSLInitializationError extends Error { 7 | 8 | public AuthSSLInitializationError() { 9 | } 10 | 11 | public AuthSSLInitializationError(String message) { 12 | super(message); 13 | } 14 | 15 | public AuthSSLInitializationError(String message, Throwable cause) { 16 | super(message, cause); 17 | } 18 | 19 | public AuthSSLInitializationError(Throwable cause) { 20 | super(cause); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/webapp/css/group_col.gif: -------------------------------------------------------------------------------- 1 | 2 | 404 Not Found 3 | 4 |

404 Not Found

5 |
nginx
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/com/app/mvc/dao/ShortUrlDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.dao; 2 | 3 | import com.app.mvc.shortUrl.ShortUrl; 4 | import com.app.mvc.shortUrl.ShortUrlDao; 5 | import org.junit.Test; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * Created by jimin on 16/4/7. 11 | */ 12 | public class ShortUrlDaoTest extends BaseJunitTest { 13 | 14 | @Resource 15 | private ShortUrlDao shortUrlDao; 16 | 17 | @Test 18 | public void testSave() { 19 | ShortUrl shortUrl = ShortUrl.builder().origin("test").current("test").status(1).build(); 20 | shortUrlDao.save(shortUrl); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysRoleDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysRole; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/1/18. 11 | */ 12 | @DBRepository 13 | public interface SysRoleDao { 14 | 15 | void save(SysRole sysRole); 16 | 17 | void update(SysRole sysRole); 18 | 19 | SysRole findById(@Param("id") int id); 20 | 21 | List getBySupplierId(@Param("supplierId") int supplierId); 22 | 23 | void deleteById(@Param("id") int id); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/test/TestQuartz.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.test; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by jimin on 15/11/21. 10 | */ 11 | @Slf4j 12 | @Component 13 | public class TestQuartz { 14 | 15 | //@Scheduled(cron = "0 0/1 * * * ?") 16 | public void execute1() { 17 | log.info("quartz 1 min " + new Date().toString()); 18 | } 19 | 20 | //@Scheduled(fixedDelay = 5000) 21 | public void execute2() { 22 | log.info("quartz delay 5000 " + new Date().toString()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/beans/Mail.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.beans; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Set; 11 | 12 | /** 13 | * Created by jimin on 15/11/21. 14 | */ 15 | @Getter 16 | @Setter 17 | @ToString 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | @Builder 21 | public class Mail { 22 | 23 | private Set receivers; // 收件人的邮箱 24 | 25 | private String subject; // 主题 26 | 27 | private String message; // 信息(支持HTML) 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/dao/InvestmentDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.dao; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import com.app.mvc.business.domain.Investment; 5 | import com.app.mvc.common.DBRepository; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jimin on 16/3/8. 12 | */ 13 | @DBRepository 14 | public interface InvestmentDao { 15 | 16 | void save(Investment investment); 17 | 18 | void invalid(@Param("id") int id, @Param("operator") String operator); 19 | 20 | int count(); 21 | 22 | List getPage(PageQuery page); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/quartz.properties: -------------------------------------------------------------------------------- 1 | org.quartz.scheduler.instanceName: CustomQuartzScheduler 2 | org.quartz.scheduler.instanceId: CustomInsranceId 3 | org.quartz.scheduler.rmi.export: false 4 | org.quartz.scheduler.rmi.proxy: false 5 | org.quartz.scheduler.wrapJobExecutionInUserTransaction: false 6 | 7 | org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool 8 | org.quartz.threadPool.threadCount: 10 9 | org.quartz.threadPool.threadPriority: 5 10 | org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true 11 | 12 | org.quartz.jobStore.misfireThreshold: 60000 13 | 14 | org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/CommonController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | /** 9 | * Created by jimin on 16/4/23. 10 | */ 11 | @Controller 12 | public class CommonController { 13 | 14 | @RequestMapping(value = "/serviceDegarding.do", method = RequestMethod.GET) 15 | public ModelAndView serviceDagardingPage() { 16 | return new ModelAndView("serviceDegarding"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/ConfigurationDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.config; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 15/11/7. 11 | */ 12 | @DBRepository 13 | public interface ConfigurationDao { 14 | 15 | Configuration findByK(@Param("k") String k); 16 | 17 | void updateByK(Configuration configuration); 18 | 19 | void insert(Configuration configuration); 20 | 21 | List getAll(); 22 | 23 | List getByPage(PageQuery pageQuery); 24 | 25 | int count(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleExecuteResultDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | /** 11 | * Created by jimin on 16/5/9. 12 | */ 13 | @Getter 14 | @Setter 15 | @ToString 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Builder 19 | public class ScheduleExecuteResultDto { 20 | 21 | private String scheduleId; 22 | 23 | private String start; 24 | 25 | private String end; 26 | 27 | private int status; 28 | 29 | private long costMillSeconds; 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/shortUrl/ShortUrl.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.shortUrl; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/4/7. 14 | */ 15 | @Getter 16 | @Setter 17 | @ToString 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | @Builder 21 | public class ShortUrl { 22 | 23 | private String origin; 24 | 25 | private String current; 26 | 27 | private int status; 28 | 29 | private Date createTime; 30 | 31 | private Date invalidTime; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/ByteUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | /** 4 | * Created by jimin on 15/12/11. 5 | */ 6 | public class ByteUtil { 7 | 8 | public static byte[] toByteArray(Long l) { 9 | byte[] b = new byte[8]; 10 | 11 | for (int i = 0; i < b.length; ++i) { 12 | b[7 - i] = (byte) ((int) (l.longValue() >>> i * 8)); 13 | } 14 | 15 | return b; 16 | } 17 | 18 | public static byte[] toByteArray(Integer i) { 19 | byte[] b = new byte[4]; 20 | 21 | for (int j = 0; j < 4; ++j) { 22 | b[3 - j] = (byte) (i.intValue() >>> j * 8); 23 | } 24 | 25 | return b; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/dao/ArticleDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.dao; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import com.app.mvc.business.domain.Article; 5 | import com.app.mvc.common.DBRepository; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jimin on 16/3/7. 12 | */ 13 | @DBRepository 14 | public interface ArticleDao { 15 | 16 | void save(Article article); 17 | 18 | void update(Article article); 19 | 20 | void incrReadTime(@Param("id") int id); 21 | 22 | Article findById(@Param("id") int id); 23 | 24 | List
getPage(PageQuery page); 25 | 26 | int count(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleExecuteResult.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/5/9. 14 | */ 15 | @Getter 16 | @Setter 17 | @ToString 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Builder 21 | public class ScheduleExecuteResult { 22 | 23 | private int id; 24 | 25 | private String scheduleId; 26 | 27 | private Date startTime; 28 | 29 | private Date endTime; 30 | 31 | private int status; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/datasource/AspectOrder.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.datasource; 2 | 3 | /** 4 | * AOP切面的执行顺序, 由小到大执行. 5 | * 如某方法m有3个切面, 都是Around类型, Order分别为1,2,3. 6 | * 则m方法的执行顺序为 1,2,3,m,3,2,1 7 | *

8 | * Created by jimin on 16/03/22. 9 | */ 10 | public interface AspectOrder { 11 | 12 | /** 13 | * 动态数据源 14 | */ 15 | int ROUTING_DATA_SOURCE = 100; 16 | 17 | /** 18 | * 事务 19 | *

20 |      *   
21 |      * 
22 | * 23 | * @see org.springframework.transaction.annotation.Transactional 24 | */ 25 | int TRANSACTIONAL = 200; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/http/CallbackAdaptor.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.http; 2 | 3 | import com.app.mvc.http.ext.AuthSSLInitializationError; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | /** 7 | * 简化HttpCallback接口的实现复杂度 8 | * Created by jimin on 16/03/10. 9 | */ 10 | @Slf4j 11 | public class CallbackAdaptor implements HttpCallback { 12 | 13 | @Override 14 | public void onSuccess(ResponseWrapper wrapper) { 15 | } 16 | 17 | @Override 18 | public void onFailure(Throwable t) { 19 | throw new RuntimeException(t.getMessage(), t); 20 | } 21 | 22 | @Override 23 | public void onAuthority(AuthSSLInitializationError t) { 24 | log.warn("认证失败", t); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/DeptConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysBase; 4 | import com.app.mvc.acl.domain.SysDept; 5 | import com.app.mvc.acl.vo.DeptPara; 6 | 7 | /** 8 | * Created by jimin on 16/1/16. 9 | */ 10 | public class DeptConvert { 11 | 12 | public static SysDept of(DeptPara para) { 13 | 14 | BaseConvert.checkPara(para); 15 | 16 | SysBase base = BaseConvert.of(); 17 | 18 | return SysDept.builder().id(para.getId()).name(para.getName()).seq(para.getSeq()).remark(para.getRemark()).parentId(para.getParentId()) 19 | .operator(base.getOperator()).operateIp(base.getOperateIp()).build(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/Configuration.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.config; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * Created by jimin on 15/11/7. 10 | */ 11 | @Getter 12 | @Setter 13 | @ToString 14 | @NoArgsConstructor 15 | public class Configuration { 16 | 17 | private String k; 18 | 19 | private String v; 20 | 21 | private String operator; 22 | 23 | private String comment; 24 | 25 | public Configuration(String k, String v, String operator, String comment) { 26 | this.k = k; 27 | this.v = v; 28 | this.operator = operator; 29 | this.comment = comment; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysRoleUserDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysRoleUser; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/1/18. 11 | */ 12 | @DBRepository 13 | public interface SysRoleUserDao { 14 | 15 | List getUserIdListByRoleId(@Param("roleId") int roleId); 16 | 17 | List getRoleIdListByUserId(@Param("userId") int userId); 18 | 19 | void deleteByRoleId(@Param("roleId") int roleId); 20 | 21 | void batchInsert(@Param("list") List list); 22 | 23 | int countByRoleId(@Param("roleId") int roleId); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysBase.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/16. 14 | */ 15 | @ToString 16 | @Getter 17 | @Setter 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class SysBase { 22 | 23 | /** 24 | * 操作者 25 | */ 26 | private String operator; 27 | /** 28 | * 操作者ip 29 | */ 30 | private String operateIp; 31 | /** 32 | * 操作时间 33 | */ 34 | private Date operateTime; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleJobSettingDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import com.app.mvc.common.DBRepository; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by jimin on 16/5/8. 10 | */ 11 | @DBRepository 12 | public interface ScheduleJobSettingDao { 13 | 14 | void save(ScheduledJobSetting setting); 15 | 16 | void update(ScheduledJobSetting setting); 17 | 18 | List getAll(); 19 | 20 | ScheduledJobSetting findById(@Param("id") int id); 21 | 22 | int countByClassPath(@Param("classPath") String classPath); 23 | 24 | List getListByGroupId(@Param("groupId") String groupId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduledJobSetting.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | /** 11 | * Created by jimin on 16/5/8. 12 | */ 13 | @Getter 14 | @Setter 15 | @ToString 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @Builder 19 | public class ScheduledJobSetting { 20 | 21 | private int id; 22 | 23 | private String scheduleId; 24 | 25 | private String groupId; 26 | 27 | private String cron; 28 | 29 | private String classPath; 30 | 31 | private int status = ScheduleJobStatus.INIT.getCode(); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/AclDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import com.app.mvc.acl.domain.SysAcl; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | import org.springframework.beans.BeanUtils; 8 | 9 | /** 10 | * Created by jimin on 16/1/24. 11 | */ 12 | @ToString 13 | @Getter 14 | @Setter 15 | public class AclDto extends SysAcl { 16 | 17 | /** 18 | * 是否默认选中 19 | */ 20 | private boolean checked = false; 21 | /** 22 | * 是否有权限操作 23 | */ 24 | private boolean hasAcl = false; 25 | 26 | public static AclDto adapt(SysAcl acl) { 27 | AclDto dto = new AclDto(); 28 | BeanUtils.copyProperties(acl, dto); 29 | return dto; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/DeptPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Length; 7 | 8 | import javax.validation.constraints.NotNull; 9 | 10 | @ToString 11 | @Getter 12 | @Setter 13 | public class DeptPara { 14 | 15 | private Integer id; 16 | 17 | @Length(min = 2, max = 25, message = "部门名称长度需要在2~25个字之间") 18 | private String name; 19 | 20 | @Length(min = 0, max = 64, message = "备注长度需要在64个字以内") 21 | private String remark; 22 | 23 | private Integer parentId; 24 | 25 | @NotNull(message = "展示顺序不可以为空") 26 | private Integer seq; 27 | 28 | private Integer supplierId; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/captcha/CaptchaCode.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.captcha; 2 | 3 | import com.app.mvc.acl.enums.Status; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/3/9. 14 | */ 15 | @Getter 16 | @Setter 17 | @Builder 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | public class CaptchaCode { 21 | 22 | private Integer id; 23 | 24 | private String code; 25 | 26 | private String sessionId; 27 | 28 | private int status = Status.AVAILABLE.getCode(); 29 | 30 | private Date expireTime; 31 | 32 | private int tryTimes = 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/SpringContextLoadListener.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.context.ContextLoaderListener; 5 | 6 | import javax.servlet.ServletContextEvent; 7 | 8 | /** 9 | * Created by jimin on 15/11/8. 10 | */ 11 | @Slf4j 12 | public class SpringContextLoadListener extends ContextLoaderListener { 13 | 14 | @Override 15 | public void contextInitialized(ServletContextEvent event) { 16 | super.contextInitialized(event); 17 | log.info("context loader initialized"); 18 | } 19 | 20 | @Override 21 | public void contextDestroyed(ServletContextEvent event) { 22 | super.contextDestroyed(event); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysRoleAclDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysRoleAcl; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/1/18. 11 | */ 12 | @DBRepository 13 | public interface SysRoleAclDao { 14 | 15 | List getAclIdListByRoleId(@Param("roleId") int roleId); 16 | 17 | List getAclIdListByRoleIdList(@Param("roleIdList") List roleIdList); 18 | 19 | void deleteByRoleId(@Param("roleId") int roleId); 20 | 21 | void batchInsert(@Param("list") List list); 22 | 23 | int countByRoleId(@Param("roleId") int roleId); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysToolDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.common.DBRepository; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.apache.ibatis.annotations.Update; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by jimin on 16/2/2. 13 | */ 14 | @DBRepository 15 | public interface SysToolDao { 16 | 17 | @Select("SELECT #{url} REGEXP #{rule}") 18 | int checkRegexp(@Param("url") String url, @Param("rule") String rule); 19 | 20 | @Select("${sql}") 21 | List executeSelect(@Param("sql") String sql); 22 | 23 | @Update("${sql}") 24 | void executeUpdate(@Param("sql") String sql); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/service/TestDataSourceService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.service; 2 | 3 | import com.app.mvc.business.dao.TestDao; 4 | import com.app.mvc.business.domain.Test; 5 | import com.app.mvc.datasource.DataSources; 6 | import com.app.mvc.datasource.RoutingDataSource; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | 11 | /** 12 | * Created by jimin on 16/3/22. 13 | */ 14 | @Service 15 | public class TestDataSourceService { 16 | 17 | @Resource 18 | private TestDao testDao; 19 | 20 | @RoutingDataSource(DataSources.LOG) 21 | public void save(String msg) { 22 | Test test = Test.builder().text(msg).build(); 23 | testDao.save(test); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/AclModuleConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysAclModule; 4 | import com.app.mvc.acl.domain.SysBase; 5 | import com.app.mvc.acl.vo.AclModulePara; 6 | 7 | /** 8 | * Created by jimin on 16/1/16. 9 | */ 10 | public class AclModuleConvert { 11 | 12 | public static SysAclModule of(AclModulePara para) { 13 | 14 | BaseConvert.checkPara(para); 15 | 16 | SysBase base = BaseConvert.of(); 17 | 18 | return SysAclModule.builder().id(para.getId()).name(para.getName()).parentId(para.getParentId()).status(para.getStatus()).seq(para.getSeq()) 19 | .remark(para.getRemark()).operator(base.getOperator()).operateIp(base.getOperateIp()).build(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resource.prod/jdbc.properties: -------------------------------------------------------------------------------- 1 | master.jdbc.driverClassName = com.mysql.jdbc.Driver 2 | master.jdbc.url = jdbc:mysql://localhost:3306/furniture?useUnicode=true&characterEncoding=UTF-8 3 | master.jdbc.username = root 4 | master.jdbc.password = 466420182 5 | 6 | log.jdbc.driverClassName = com.mysql.jdbc.Driver 7 | log.jdbc.url = jdbc:mysql://localhost:3306/log?useUnicode=true&characterEncoding=UTF-8 8 | log.jdbc.username = root 9 | log.jdbc.password = 466420182 10 | 11 | test.jdbc.driverClassName = com.mysql.jdbc.Driver 12 | test.jdbc.url = jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8 13 | test.jdbc.username = root 14 | test.jdbc.password = 466420182 -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/AclConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysAcl; 4 | import com.app.mvc.acl.domain.SysBase; 5 | import com.app.mvc.acl.vo.AclPara; 6 | 7 | /** 8 | * Created by jimin on 16/1/16. 9 | */ 10 | public class AclConvert { 11 | 12 | public static SysAcl of(AclPara para) { 13 | 14 | BaseConvert.checkPara(para); 15 | 16 | SysBase base = BaseConvert.of(); 17 | 18 | return SysAcl.builder().id(para.getId()).name(para.getName()).aclModuleId(para.getAclModuleId()).url(para.getUrl()).type(para.getType()) 19 | .status(para.getStatus()).seq(para.getSeq()).remark(para.getRemark()).operator(base.getOperator()).operateIp(base.getOperateIp()).build(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/exception/ParaException.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.exception; 2 | 3 | /** 4 | * Created by jimin on 15/11/5. 5 | */ 6 | public class ParaException extends RuntimeException { 7 | 8 | public ParaException() { 9 | super(); 10 | } 11 | 12 | public ParaException(String message) { 13 | super(message); 14 | } 15 | 16 | public ParaException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public ParaException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | protected ParaException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 25 | super(message, cause, enableSuppression, writableStackTrace); 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleJobDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | /** 11 | * Created by jimin on 16/5/14. 12 | */ 13 | @Getter 14 | @Setter 15 | @ToString 16 | @NoArgsConstructor 17 | @AllArgsConstructor 18 | @Builder 19 | public class ScheduleJobDto { 20 | 21 | private int id; 22 | 23 | private String groupId; 24 | 25 | private String scheduleId; 26 | 27 | private String cron; 28 | 29 | private int status; 30 | 31 | private String lastExecuteTime; 32 | 33 | private String nextExecuteTime; 34 | 35 | private long costMillSeconds; 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/AclModulePara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Length; 7 | 8 | import javax.validation.constraints.NotNull; 9 | 10 | @ToString 11 | @Getter 12 | @Setter 13 | public class AclModulePara { 14 | 15 | private Integer id; 16 | 17 | @Length(min = 2, max = 64, message = "权限模块名称长度需要在2~64个字之间") 18 | private String name; 19 | 20 | @NotNull(message = "权限模块展示顺序不能为空") 21 | private Integer seq; 22 | 23 | @Length(min = 0, max = 64, message = "备注长度需要在64个字以内") 24 | private String remark; 25 | 26 | @NotNull(message = "权限模块状态不能为空") 27 | private int status; 28 | 29 | private Integer parentId; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/captcha/CaptchaCodeDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.captcha; 2 | 3 | import com.app.mvc.common.DBRepository; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by jimin on 16/3/9. 10 | */ 11 | @DBRepository 12 | public interface CaptchaCodeDao { 13 | 14 | void save(CaptchaCode captchaCode); 15 | 16 | void incrTryTimes(@Param("id") int id); 17 | 18 | CaptchaCode findById(@Param("id") int id); 19 | 20 | CaptchaCode findLastBySessionId(@Param("sessionId") String sessionId); 21 | 22 | int countBySessionIdAndCreateTime(@Param("sessionId") String sessionId, @Param("targetTime") Date targetTime); 23 | 24 | void invalidCaptchaCode(@Param("sessionId") String sessionId, @Param("code") String code); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/proxy/UrlConnectionChecker.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.proxy; 2 | 3 | import org.apache.http.client.HttpClient; 4 | import org.apache.http.client.methods.HttpGet; 5 | import org.apache.http.client.methods.HttpPost; 6 | 7 | /** 8 | * Created by jimin on 16/5/3. 9 | */ 10 | public interface UrlConnectionChecker { 11 | 12 | /** 13 | * 检查使用的url 14 | * 注意: 不需要保证url的参数的正确性, 处理的是http状态码 15 | */ 16 | String url(); 17 | 18 | /** 19 | * 如果是Post请求, 需要给出该类的实例, 否则为空 20 | * 注意: 如果需要设置header及往body里放置data等, 都在返回的实例上设置好 21 | */ 22 | HttpPost httpPost(); 23 | 24 | /** 25 | * 如果是Get请求, 需要给出该类的实例, 否则为空 26 | */ 27 | HttpGet httpGet(); 28 | 29 | /** 30 | * 检查使用的httpClient 31 | */ 32 | HttpClient httpClient(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/ScheduleExecuteResultDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/5/8. 11 | */ 12 | @DBRepository 13 | public interface ScheduleExecuteResultDao { 14 | 15 | void save(ScheduleExecuteResult setting); 16 | 17 | void update(ScheduleExecuteResult setting); 18 | 19 | List getPageByScheduleId(@Param("scheduleId") String scheduleId, @Param("page") PageQuery page); 20 | 21 | int countByScheduleId(@Param("scheduleId") String scheduleId); 22 | 23 | ScheduleExecuteResult findLastExecute(@Param("scheduleId") String scheduleId); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/RoleConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysBase; 4 | import com.app.mvc.acl.domain.SysRole; 5 | import com.app.mvc.acl.vo.RolePara; 6 | import com.app.mvc.exception.ParaException; 7 | 8 | /** 9 | * Created by jimin on 16/1/16. 10 | */ 11 | public class RoleConvert { 12 | 13 | public static SysRole of(RolePara para) throws ParaException { 14 | 15 | BaseConvert.checkPara(para); 16 | 17 | SysBase base = BaseConvert.of(); 18 | 19 | return SysRole.builder().id(para.getId()).status(para.getStatus()).name(para.getName()).supplierId(para.getSupplierId()).remark(para.getRemark()) 20 | .type(para.getType()).operator(base.getOperator()).operateIp(base.getOperateIp()).build(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/CacheKeyConstants.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.enums; 2 | 3 | import lombok.Getter; 4 | 5 | /** 6 | * 缓存的前缀, 统一管理 7 | * Created by jimin on 16/2/4. 8 | */ 9 | @Getter 10 | public enum CacheKeyConstants { 11 | 12 | /** 13 | * 缓存用户的信息 14 | */ 15 | USERID_USER, 16 | 17 | /** 18 | * 缓存用户的信息 19 | */ 20 | USERNAME_USER, 21 | 22 | /** 23 | * 缓存用户拥有的权限点 24 | */ 25 | USERID_ACLLIST, 26 | 27 | /** 28 | * 缓存用户拥有的权限树 29 | */ 30 | USERID_ACLTREE, 31 | 32 | /** 33 | * 缓存用户校验过的权限点,可能有权限,可能无权限 34 | */ 35 | USERID_ACLCODE, 36 | 37 | /** 38 | * 缓存用户校验过的url,可能有权限,可能无权限 39 | */ 40 | USERID_URL, 41 | 42 | /** 43 | * 缓存系统中校验的url 44 | */ 45 | SYS_URL_LIST 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/exception/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.exception; 2 | 3 | /** 4 | * Created by jimin on 15/11/7. 5 | */ 6 | public class NotFoundException extends RuntimeException { 7 | 8 | public NotFoundException() { 9 | super(); 10 | } 11 | 12 | public NotFoundException(String message) { 13 | super(message); 14 | } 15 | 16 | public NotFoundException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | public NotFoundException(Throwable cause) { 21 | super(cause); 22 | } 23 | 24 | protected NotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 25 | super(message, cause, enableSuppression, writableStackTrace); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/webapp/js/ie10-viewport-bug-workaround.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | 7 | // See the Getting Started docs for more information: 8 | // http://getbootstrap.com/getting-started/#support-ie10-width 9 | 10 | (function () { 11 | 'use strict'; 12 | 13 | if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 14 | var msViewportStyle = document.createElement('style') 15 | msViewportStyle.appendChild( 16 | document.createTextNode( 17 | '@-ms-viewport{width:auto!important}' 18 | ) 19 | ) 20 | document.querySelector('head').appendChild(msViewportStyle) 21 | } 22 | 23 | })(); -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/http/HttpCallback.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.http; 2 | 3 | import com.app.mvc.http.ext.AuthSSLInitializationError; 4 | import com.google.common.util.concurrent.FutureCallback; 5 | 6 | /** 7 | * http回调接口 8 | * Created by jimin on 16/03/10. 9 | */ 10 | public interface HttpCallback extends FutureCallback { 11 | 12 | /** 13 | * 正确返回的时候将调用此方法 14 | * 15 | * @param wrapper ResponseWrapper 16 | */ 17 | void onSuccess(ResponseWrapper wrapper); 18 | 19 | /** 20 | * 产生异常的时候调用此方法 21 | * 22 | * @param t Throwable 23 | */ 24 | void onFailure(Throwable t); 25 | 26 | /** 27 | * https 认证失败调用 28 | * 29 | * @param t AuthSSLInitializationError 30 | */ 31 | void onAuthority(AuthSSLInitializationError t); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import com.app.mvc.acl.domain.SysUser; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * Created by jimin on 16/2/10. 9 | */ 10 | @Getter 11 | @Setter 12 | public class LoginUser { 13 | 14 | private boolean ret = false; 15 | 16 | private SysUser user; 17 | 18 | private String msg; 19 | 20 | public LoginUser(boolean ret, SysUser user, String msg) { 21 | this.ret = ret; 22 | this.user = user; 23 | this.msg = msg; 24 | } 25 | 26 | public static LoginUser success(SysUser user) { 27 | return new LoginUser(true, user, null); 28 | } 29 | 30 | public static LoginUser fail(String msg) { 31 | return new LoginUser(false, null, msg); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysLogDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysLog; 4 | import com.app.mvc.acl.dto.LogSearchDto; 5 | import com.app.mvc.beans.PageQuery; 6 | import com.app.mvc.common.DBRepository; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by jimin on 16/1/18. 13 | */ 14 | @DBRepository 15 | public interface SysLogDao { 16 | 17 | void save(SysLog log); 18 | 19 | /** 20 | * 根据id查询某条记录 21 | * 用于撤回某次操作 22 | */ 23 | SysLog findById(@Param("id") int id); 24 | 25 | /** 26 | * 模糊匹配更新记录 27 | */ 28 | List fuzzySearch(@Param("dto") LogSearchDto dto, @Param("page") PageQuery page); 29 | 30 | int countFuzzySearch(@Param("dto") LogSearchDto dto); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/rabbitmq/MessageProduceService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.rabbitmq; 2 | 3 | import com.app.mvc.config.GlobalConfig; 4 | import com.app.mvc.config.GlobalConfigKey; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * Created by jimin on 16/3/11. 10 | */ 11 | @Service("messageProduceService") 12 | public class MessageProduceService { 13 | 14 | // @Autowired 15 | private AmqpTemplate template; 16 | 17 | public void pushToMessageQueue(String routingKey, String message) { 18 | template.convertAndSend(routingKey, message); 19 | } 20 | 21 | public void pushToMessageQueue(String message) { 22 | pushToMessageQueue(GlobalConfig.getStringValue(GlobalConfigKey.RABBITMQ_DEFAULT_QUEUE_NAME, "testQ"), message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/UserConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysBase; 4 | import com.app.mvc.acl.domain.SysUser; 5 | import com.app.mvc.acl.vo.UserPara; 6 | 7 | /** 8 | * Created by jimin on 16/1/16. 9 | */ 10 | public class UserConvert { 11 | 12 | public static SysUser of(UserPara para) { 13 | 14 | BaseConvert.checkPara(para); 15 | 16 | SysBase base = BaseConvert.of(); 17 | 18 | return SysUser.builder().id(para.getId()).username(para.getUsername()).telephone(para.getTelephone()).mail(para.getMail()).remark(para.getRemark()) 19 | .deptId(para.getDeptId()).status(para.getStatus()).supplierId(para.getSupplierId()).managedSupplierIds(para.getManagedSupplierIds()) 20 | .operator(base.getOperator()).operateIp(base.getOperateIp()).build(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/AclModuleLevelDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import com.app.mvc.acl.domain.SysAclModule; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | import org.springframework.beans.BeanUtils; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by jimin on 16/1/24. 13 | */ 14 | @ToString 15 | @Getter 16 | @Setter 17 | public class AclModuleLevelDto extends SysAclModule { 18 | 19 | /** 20 | * 组装权限模块层级使用 21 | */ 22 | private List aclModuleList; 23 | /** 24 | * 组装权限层级模块下的权限点列表 25 | */ 26 | private List aclList; 27 | 28 | public static AclModuleLevelDto adapt(SysAclModule aclModule) { 29 | AclModuleLevelDto dto = new AclModuleLevelDto(); 30 | BeanUtils.copyProperties(aclModule, dto); 31 | return dto; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/util/LevelUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * Created by jimin on 16/1/16. 7 | */ 8 | 9 | public class LevelUtil { 10 | 11 | // 层级间的分隔符 12 | public final static String SEPARATOR = "."; 13 | 14 | public final static String ROOT = "0"; 15 | 16 | /** 17 | * 传入父层级,计算子层级 18 | * 19 | * @param parentLevel 父节点的层级 20 | * @param parentId 父节点的id 21 | * @return 当前节点的层级 22 | */ 23 | public static String calculateLevel(String parentLevel, int parentId) { 24 | if (StringUtils.isBlank(parentLevel)) { 25 | // 首层是0 26 | return String.valueOf(ROOT); 27 | } else { 28 | // 非首层:父层level.父层id 29 | return StringUtils.join(parentLevel, SEPARATOR, parentId); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysRoleUser.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/16. 14 | */ 15 | 16 | @ToString 17 | @Getter 18 | @Setter 19 | @Builder 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class SysRoleUser { 23 | 24 | private Integer id; 25 | /** 26 | * 角色id 27 | */ 28 | private int roleId; 29 | /** 30 | * 用户id 31 | */ 32 | private int userId; 33 | /** 34 | * 操作者 35 | */ 36 | private String operator; 37 | /** 38 | * 操作者ip 39 | */ 40 | private String operateIp; 41 | /** 42 | * 操作时间 43 | */ 44 | private Date operateTime; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysRoleAcl.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/16. 14 | */ 15 | 16 | @ToString 17 | @Getter 18 | @Setter 19 | @Builder 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class SysRoleAcl { 23 | 24 | private Integer id; 25 | /** 26 | * 角色id 27 | */ 28 | private Integer roleId; 29 | /** 30 | * 权限点id 31 | */ 32 | private Integer aclId; 33 | /** 34 | * 操作者 35 | */ 36 | private String operator; 37 | /** 38 | * 操作者ip 39 | */ 40 | private String operateIp; 41 | /** 42 | * 操作时间 43 | */ 44 | private Date operateTime; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/FileInfo.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.domain; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * Created by jimin on 15/11/29. 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | public class FileInfo { 16 | 17 | private int id; 18 | 19 | private String originName; 20 | 21 | private String name; 22 | 23 | private String operator; 24 | 25 | private Date operateTime; 26 | 27 | private String md5; 28 | 29 | private long size; 30 | 31 | public FileInfo() { 32 | } 33 | 34 | public FileInfo(String originName, String name, String operator, String md5, long size) { 35 | this.originName = originName; 36 | this.name = name; 37 | this.operator = operator; 38 | this.md5 = md5; 39 | this.size = size; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/datasource/DynamicDataSource.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.datasource; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 5 | 6 | import java.sql.Connection; 7 | import java.sql.SQLException; 8 | 9 | /** 10 | * 动态数据源 11 | * Created by jimin on 16/03/22. 12 | */ 13 | @Slf4j 14 | public class DynamicDataSource extends AbstractRoutingDataSource { 15 | 16 | protected Object determineCurrentLookupKey() { 17 | return DataSourceKeyHolder.getCurrentKey(); 18 | } 19 | 20 | @Override 21 | public Connection getConnection() throws SQLException { 22 | Connection connection = super.getConnection(); 23 | if (DataSourceKeyHolder.getCurrentKey() != null) { 24 | log.info("Datasource route to {}, key={}", connection, DataSourceKeyHolder.getCurrentKey()); 25 | } 26 | return connection; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/DeptLevelDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import com.app.mvc.acl.domain.SysDept; 4 | import com.app.mvc.acl.domain.SysUser; 5 | import com.google.common.collect.Lists; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | import org.springframework.beans.BeanUtils; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by jimin on 16/1/24. 15 | */ 16 | @Getter 17 | @Setter 18 | @ToString 19 | public class DeptLevelDto extends SysDept { 20 | /** 21 | * 组装部门层级使用 22 | */ 23 | private List deptList = Lists.newArrayList(); 24 | /** 25 | * 组装部门层级下用户列表 26 | */ 27 | private List userList = Lists.newArrayList(); 28 | 29 | public static DeptLevelDto adapt(SysDept dept) { 30 | DeptLevelDto dto = new DeptLevelDto(); 31 | BeanUtils.copyProperties(dept, dto); 32 | return dto; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/RolePara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Length; 7 | 8 | import javax.validation.constraints.Max; 9 | import javax.validation.constraints.Min; 10 | 11 | @ToString 12 | @Getter 13 | @Setter 14 | public class RolePara { 15 | 16 | private Integer id; 17 | 18 | @Length(min = 4, max = 32, message = "角色名称长度需要在4~32个字之间") 19 | private String name; 20 | 21 | @Length(min = 0, max = 64, message = "备注长度需要在64个字以内") 22 | private String remark; 23 | 24 | private int supplierId = 0; 25 | 26 | /** 27 | * @see com.app.mvc.acl.enums.Status 28 | */ 29 | @Min(0) 30 | @Max(1) 31 | private int status = 1; 32 | 33 | /** 34 | * @see com.app.mvc.acl.enums.RoleType 35 | */ 36 | @Min(0) 37 | @Max(2) 38 | private int type = 0; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysDeptDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysDept; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/1/18. 11 | */ 12 | @DBRepository 13 | public interface SysDeptDao { 14 | 15 | void save(SysDept sysDept); 16 | 17 | void update(SysDept sysDept); 18 | 19 | SysDept findById(@Param("id") int id); 20 | 21 | void deleteById(@Param("id") int id); 22 | 23 | List getBySupplierId(@Param("supplierId") int supplierId); 24 | 25 | List getChildDeptListByLevel(@Param("level") String level); 26 | 27 | void batchUpdateLevel(@Param("deptList") List deptList); 28 | 29 | int countByParentId(@Param("id") int id); 30 | 31 | int countByNameAndParentId(@Param("parentId") int parentId, @Param("name") String name, @Param("id") Integer id); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/datasource/DataSourceKeyHolder.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.datasource; 2 | 3 | import java.util.LinkedList; 4 | 5 | /** 6 | * 保存一个线程中的动态数据源的key 7 | * Created by jimin on 16/03/22. 8 | */ 9 | public class DataSourceKeyHolder { 10 | 11 | private static final ThreadLocal> holder = new ThreadLocal>() { 12 | @Override 13 | protected LinkedList initialValue() { 14 | return new LinkedList<>(); 15 | } 16 | }; 17 | 18 | public static void set(String key) { 19 | holder.get().push(key); 20 | } 21 | 22 | public static void clear() { 23 | holder.get().pop(); 24 | } 25 | 26 | public static String getCurrentKey() { 27 | if (holder.get().size() == 0) 28 | return null; 29 | return holder.get().getFirst(); 30 | } 31 | 32 | public static boolean isNestedCall() { 33 | return holder.get().size() > 1; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/webapp/css/signin.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 40px; 3 | padding-bottom: 40px; 4 | background-color: #eee; 5 | } 6 | 7 | .form-signin { 8 | max-width: 330px; 9 | padding: 15px; 10 | margin: 0 auto; 11 | } 12 | .form-signin .form-signin-heading, 13 | .form-signin .checkbox { 14 | margin-bottom: 10px; 15 | } 16 | .form-signin .checkbox { 17 | font-weight: normal; 18 | } 19 | .form-signin .form-control { 20 | position: relative; 21 | height: auto; 22 | -webkit-box-sizing: border-box; 23 | -moz-box-sizing: border-box; 24 | box-sizing: border-box; 25 | padding: 10px; 26 | font-size: 16px; 27 | } 28 | .form-signin .form-control:focus { 29 | z-index: 2; 30 | } 31 | .form-signin input[type="email"] { 32 | margin-bottom: -1px; 33 | border-bottom-right-radius: 0; 34 | border-bottom-left-radius: 0; 35 | } 36 | .form-signin input[type="password"] { 37 | margin-bottom: 10px; 38 | border-top-left-radius: 0; 39 | border-top-right-radius: 0; 40 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dto/LogSearchDto.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dto; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import lombok.ToString; 8 | 9 | import java.sql.Timestamp; 10 | 11 | /** 12 | * Created by jimin on 16/1/23. 13 | */ 14 | @ToString 15 | @Getter 16 | @Setter 17 | @Builder 18 | public class LogSearchDto extends PageQuery { 19 | /** 20 | * log类型 21 | * 22 | * @see com.app.mvc.acl.enums.LogType 23 | */ 24 | private Integer type; 25 | /** 26 | * 指定的id 27 | */ 28 | private Integer targetId; 29 | /** 30 | * 原值 31 | */ 32 | private String beforeSeg; 33 | /** 34 | * 新值 35 | */ 36 | private String afterSeg; 37 | /** 38 | * 更新人 39 | */ 40 | private String operator; 41 | /** 42 | * 开始时间 43 | */ 44 | private Timestamp fromTime; 45 | /** 46 | * 结束时间 47 | */ 48 | private Timestamp toTime; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/LogPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import com.app.mvc.beans.PageQuery; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * Created by jimin on 16/1/23. 10 | */ 11 | @ToString 12 | @Getter 13 | @Setter 14 | public class LogPara extends PageQuery { 15 | /** 16 | * log类型 17 | * 18 | * @see com.app.mvc.acl.enums.LogType 19 | */ 20 | private Integer type; 21 | /** 22 | * 指定的id 23 | */ 24 | private Integer targetId; 25 | /** 26 | * 原值 27 | */ 28 | private String beforeSeg; 29 | /** 30 | * 新值 31 | */ 32 | private String afterSeg; 33 | /** 34 | * 更新人 35 | */ 36 | private String operator; 37 | /** 38 | * 开始时间 39 | * yyyy-[m]m-[d]d hh:mm:ss[.f...] 40 | */ 41 | private String fromTime; 42 | /** 43 | * 结束时间 44 | * yyyy-[m]m-[d]d hh:mm:ss[.f...] 45 | */ 46 | private String toTime; 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/util/RequestHolder.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.util; 2 | 3 | import com.app.mvc.acl.domain.SysUser; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | /** 8 | * Created by jimin on 16/1/16. 9 | */ 10 | public class RequestHolder { 11 | 12 | private static final ThreadLocal userHolder = new ThreadLocal<>(); 13 | 14 | private static final ThreadLocal requestHolder = new ThreadLocal<>(); 15 | 16 | public static void add(SysUser sysUser) { 17 | userHolder.set(sysUser); 18 | } 19 | 20 | public static void add(HttpServletRequest request) { 21 | requestHolder.set(request); 22 | } 23 | 24 | public static SysUser getCurrentUser() { 25 | return userHolder.get(); 26 | } 27 | 28 | public static HttpServletRequest getCurrentRequest() { 29 | return requestHolder.get(); 30 | } 31 | 32 | public static void remove() { 33 | userHolder.remove(); 34 | requestHolder.remove(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/SpringHelper.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.context.ApplicationContext; 5 | 6 | /** 7 | * Created by jimin on 15/11/21. 8 | */ 9 | @Slf4j 10 | public class SpringHelper { 11 | 12 | private static ApplicationContext applicationContext; 13 | 14 | /** 15 | * @param applicationContext 16 | * @see ApplicationContextHelper 17 | */ 18 | public static void setApplicationContext(ApplicationContext applicationContext) { 19 | SpringHelper.applicationContext = applicationContext; 20 | } 21 | 22 | public static T popBean(Class clazz) { 23 | if (applicationContext == null) 24 | return null; 25 | return applicationContext.getBean(clazz); 26 | } 27 | 28 | public static T popBean(String name, Class clazz) { 29 | if (applicationContext == null) 30 | return null; 31 | return applicationContext.getBean(name, clazz); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/beans/PageQuery.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.beans; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | import javax.validation.constraints.Max; 8 | import javax.validation.constraints.Min; 9 | 10 | /** 11 | * Created by jimin on 15/11/4. 12 | */ 13 | 14 | @ToString 15 | public class PageQuery { 16 | 17 | /** 18 | * 当前页码 19 | */ 20 | @Min(value = 1, message = "当前页码不合法") 21 | @Getter 22 | @Setter 23 | private int pageNo = 1; 24 | 25 | /** 26 | * 每页数目 27 | */ 28 | @Min(value = 1, message = "每页展示数量不合法") 29 | @Getter 30 | @Setter 31 | private int pageSize = 10; 32 | 33 | /** 34 | * 偏移量 35 | */ 36 | @Setter 37 | private int offset; 38 | 39 | /** 40 | * 是否使用排序,用于扩展 41 | * 1:使用,0:不使用 42 | */ 43 | @Getter 44 | @Setter 45 | @Min(0) 46 | @Max(1) 47 | private int order = 1; 48 | 49 | public int getOffset() { 50 | return (pageNo - 1) * pageSize; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ShortUrlMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | origin, 11 | current, 12 | status, 13 | create_time as createTime, 14 | invalid_time as invalidTime 15 | 16 | 17 | 18 | INSERT INTO short_url 19 | (origin, current, status, create_time, invalid_time) 20 | VALUES 21 | (#{origin}, #{current}, #{status}, now(), #{invalidTime}) 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/Article.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/3/7. 14 | */ 15 | @ToString 16 | @Getter 17 | @Setter 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class Article { 22 | 23 | private Integer id; 24 | 25 | /** 26 | * 内容 27 | */ 28 | private String content; 29 | /** 30 | * 阅读次数 31 | */ 32 | private int readTimes; 33 | /** 34 | * 标题 35 | */ 36 | private String title; 37 | /** 38 | * 发布时间 39 | */ 40 | private Date publishTime; 41 | /** 42 | * 操作者 43 | */ 44 | private String operator; 45 | /** 46 | * 操作者ip 47 | */ 48 | private String operateIp; 49 | /** 50 | * 操作时间 51 | */ 52 | private Date operateTime; 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/ApplicationContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.schedule.AutoRegisterScheduleJob; 4 | import com.app.mvc.schedule.ScheduleService; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.BeansException; 7 | import org.springframework.context.ApplicationContext; 8 | import org.springframework.context.ApplicationContextAware; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * Created by jimin on 15/11/7. 13 | */ 14 | @Slf4j 15 | @Component("applicationContextHelper") 16 | public class ApplicationContextHelper implements ApplicationContextAware { 17 | 18 | @Override 19 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 20 | SpringHelper.setApplicationContext(applicationContext); 21 | InitData.start(); 22 | AutoRegisterScheduleJob.registerWhenStartUp(); 23 | ScheduleService scheduleService = SpringHelper.popBean(ScheduleService.class); 24 | scheduleService.scheduleAll(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/SerializableUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.ObjectInputStream; 7 | import java.io.ObjectOutputStream; 8 | 9 | /** 10 | * Created by jimin on 16/5/5. 11 | */ 12 | public class SerializableUtil { 13 | 14 | /** 15 | * 序列化 16 | * 17 | * @param obj 18 | * @return 19 | */ 20 | public static byte[] writeObject(Object obj) throws IOException { 21 | ByteArrayOutputStream buf = new ByteArrayOutputStream(); 22 | ObjectOutputStream out = new ObjectOutputStream(buf); 23 | out.writeObject(obj); 24 | 25 | return buf.toByteArray(); 26 | } 27 | 28 | /** 29 | * 返序列化 30 | * 31 | * @param data 32 | * @return 33 | */ 34 | public static Object readObject(byte[] data) throws Exception { 35 | ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data)); 36 | return in.readObject(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/servlet/LogoutServlet.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.servlet; 2 | 3 | import com.app.mvc.acl.util.LoginUtil; 4 | import com.app.mvc.acl.util.RequestHolder; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Created by jimin on 15/11/23. 15 | */ 16 | @Slf4j 17 | public class LogoutServlet extends HttpServlet { 18 | 19 | @Override 20 | public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 21 | doPost(req, resp); 22 | } 23 | 24 | @Override 25 | public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 26 | // log.info("{} logout", RequestHolder.getCurrentUser().getUsername()); 27 | LoginUtil.logout(req, resp); 28 | resp.sendRedirect("index.jsp"); 29 | return; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysLog.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/18. 14 | */ 15 | @Getter 16 | @Setter 17 | @Builder 18 | @ToString 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class SysLog { 22 | 23 | private int id; 24 | /** 25 | * log类型 26 | * 27 | * @see com.app.mvc.acl.enums.LogType 28 | */ 29 | private int type; 30 | /** 31 | * 更新的行id 32 | */ 33 | private int targetId; 34 | /** 35 | * 更新前数据 36 | */ 37 | private String oldValue; 38 | /** 39 | * 更新后数据 40 | */ 41 | private String newValue; 42 | /** 43 | * 操作者 44 | */ 45 | private String operator; 46 | /** 47 | * 操作者ip 48 | */ 49 | private String operateIp; 50 | /** 51 | * 操作时间 52 | */ 53 | private Date operateTime; 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysAclDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysAcl; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.common.DBRepository; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jimin on 16/1/18. 12 | */ 13 | @DBRepository 14 | public interface SysAclDao { 15 | 16 | void save(SysAcl acl); 17 | 18 | void update(SysAcl acl); 19 | 20 | SysAcl findById(@Param("id") int id); 21 | 22 | SysAcl findByCode(@Param("code") String code); 23 | 24 | List getByUrlRegexp(@Param("url") String url); 25 | 26 | List getPageByAclModuleId(@Param("aclModuleId") int aclModuleId, @Param("page") PageQuery page); 27 | 28 | int countByAclModuleId(@Param("aclModuleId") int aclModuleId); 29 | 30 | int countByNameAndAclModuleId(@Param("aclModuleId") int aclModuleId, @Param("name") String name, @Param("id") Integer id); 31 | 32 | List getByIdList(@Param("idList") List idList); 33 | 34 | List getAll(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/bo/FileUploadBo.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.bo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | 7 | /** 8 | * Created by jimin on 15/11/29. 9 | */ 10 | @Getter 11 | @Setter 12 | @ToString 13 | public class FileUploadBo { 14 | 15 | private String originFileName; 16 | 17 | private String pathName; 18 | 19 | private boolean ret; 20 | 21 | private String errMsg; 22 | 23 | public FileUploadBo() { 24 | } 25 | 26 | public FileUploadBo(String originFileName, String pathName, boolean ret, String errMsg) { 27 | this.originFileName = originFileName; 28 | this.pathName = pathName; 29 | this.ret = ret; 30 | this.errMsg = errMsg; 31 | } 32 | 33 | public static FileUploadBo success(String originFileName, String pathName) { 34 | return new FileUploadBo(originFileName, pathName, true, ""); 35 | } 36 | 37 | public static FileUploadBo failed(String originFileName, String errMsg) { 38 | return new FileUploadBo(originFileName, "", false, errMsg); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/test/TestThreadGroup.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.test; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * Created by jimin on 16/3/20. 7 | */ 8 | @Slf4j 9 | public class TestThreadGroup { 10 | public static void main(String[] args) { 11 | ThreadGroup group = Thread.currentThread().getThreadGroup(); 12 | ThreadGroup topGroup = group; 13 | // 遍历线程组树,获取根线程组 14 | while (group != null) { 15 | topGroup = group; 16 | group = group.getParent(); 17 | } 18 | // 激活的线程数加倍 19 | int estimatedSize = topGroup.activeCount() * 2; 20 | Thread[] slackList = new Thread[estimatedSize]; 21 | // 获取根线程组的所有线程 22 | int actualSize = topGroup.enumerate(slackList); 23 | // copy into a list that is the exact size 24 | Thread[] list = new Thread[actualSize]; 25 | System.arraycopy(slackList, 0, list, 0, actualSize); 26 | log.info("Thread list size == " + list.length); 27 | for (Thread thread : list) { 28 | log.info(thread.getName()); 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/TimePointUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import static com.google.common.base.Preconditions.checkArgument; 4 | 5 | /** 6 | * 时间点压缩,解压工具类,用于将时间点(小时,分钟)进行压缩,使其 7 | * 成为一个新的组合数字,减少存储和传输所占的空间 8 | * Created by jimin on 16/3/10 9 | */ 10 | public class TimePointUtil { 11 | 12 | private static final int HALF_SHIFT = 8; 13 | 14 | /** 15 | * 返回结果一定是2个item的数组: 16 | *
    17 | *
  1. ret[0]是hour
  2. 18 | *
  3. ret[1]是minute
  4. 19 | *
20 | * 21 | * @return 22 | */ 23 | public static short[] decode(short val) { 24 | return new short[] { (short) (val >> HALF_SHIFT), (short) (val & 0xFF) }; 25 | } 26 | 27 | /** 28 | * hour: [0,23] , minute: [0,59] 29 | * 30 | * @param hour 31 | * @param minute 32 | * @return 33 | */ 34 | public static short encode(short hour, short minute) { 35 | checkArgument(hour >= 0 && hour < 24, "小时应该:[0,23]"); 36 | checkArgument(minute >= 0 && minute < 60, "分钟应该:[0,59]"); 37 | return (short) (hour << HALF_SHIFT | (minute)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/LogConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.dto.LogSearchDto; 4 | import com.app.mvc.acl.vo.LogPara; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | import java.sql.Timestamp; 8 | 9 | /** 10 | * Created by jimin on 16/1/23. 11 | */ 12 | public class LogConvert { 13 | 14 | public static LogSearchDto of(LogPara para) { 15 | 16 | LogSearchDto dto = LogSearchDto.builder() 17 | .type(para.getType()) 18 | .beforeSeg(StringUtils.isBlank(para.getBeforeSeg()) ? null : "%" + para.getBeforeSeg() + "%") 19 | .afterSeg(StringUtils.isBlank(para.getAfterSeg()) ? null : "%" + para.getAfterSeg() + "%") 20 | .operator(StringUtils.isBlank(para.getOperator()) ? null : "%" + para.getOperator() + "%") 21 | .fromTime(StringUtils.isBlank(para.getFromTime()) ? null : Timestamp.valueOf(para.getFromTime())) 22 | .toTime(StringUtils.isBlank(para.getToTime()) ? null : Timestamp.valueOf(para.getToTime())) 23 | .build(); 24 | return dto; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/convert/BaseConvert.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.convert; 2 | 3 | import com.app.mvc.acl.domain.SysBase; 4 | import com.app.mvc.acl.domain.SysUser; 5 | import com.app.mvc.acl.util.RequestHolder; 6 | import com.app.mvc.exception.ParaException; 7 | import com.app.mvc.util.BeanValidator; 8 | import com.app.mvc.util.IpUtil; 9 | import org.apache.commons.collections.MapUtils; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import java.util.Map; 13 | 14 | /** 15 | * Created by jimin on 16/1/16. 16 | */ 17 | public class BaseConvert { 18 | 19 | public static SysBase of() { 20 | SysUser sysUser = RequestHolder.getCurrentUser(); 21 | HttpServletRequest request = RequestHolder.getCurrentRequest(); 22 | return SysBase.builder().operator(sysUser.getUsername()).operateIp(IpUtil.getRemoteIp(request)).build(); 23 | } 24 | 25 | public static void checkPara(Object para) throws ParaException { 26 | Map errors = BeanValidator.validateForObjects(para); 27 | if (MapUtils.isNotEmpty(errors)) { 28 | throw new ParaException(errors.toString()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysDept.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/16. 14 | */ 15 | 16 | @ToString 17 | @Getter 18 | @Setter 19 | @Builder 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class SysDept { 23 | 24 | private Integer id; 25 | /** 26 | * 部门名称 27 | */ 28 | private String name; 29 | /** 30 | * 所属供应商 31 | */ 32 | private int supplierId; 33 | /** 34 | * 部门层级 35 | */ 36 | private String level; 37 | /** 38 | * 部门所在层级序号 39 | */ 40 | private int seq; 41 | /** 42 | * 备注 43 | */ 44 | private String remark; 45 | /** 46 | * 所属父部门 47 | */ 48 | private int parentId; 49 | /** 50 | * 操作者 51 | */ 52 | private String operator; 53 | /** 54 | * 操作者ip 55 | */ 56 | private String operateIp; 57 | /** 58 | * 操作时间 59 | */ 60 | private Date operateTime; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysAclModuleDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysAclModule; 4 | import com.app.mvc.common.DBRepository; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jimin on 16/1/18. 11 | */ 12 | @DBRepository 13 | public interface SysAclModuleDao { 14 | 15 | void save(SysAclModule aclModule); 16 | 17 | void update(SysAclModule aclModule); 18 | 19 | SysAclModule findById(@Param("id") int id); 20 | 21 | List getByIdList(@Param("idList") List idList); 22 | 23 | List getUniqueLevelByIdList(@Param("idList") List idList); 24 | 25 | int countByNameAndParentId(@Param("parentId") int parentId, @Param("name") String name, @Param("id") Integer id); 26 | 27 | List getAll(); 28 | 29 | int count(); 30 | 31 | List getChildModuleListByLevel(@Param("level") String level); 32 | 33 | void batchUpdateLevel(@Param("aclModuleList") List aclModuleList); 34 | 35 | int countByParentId(@Param("parentId") int parentId); 36 | 37 | void deleteById(@Param("id") int id); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/redis/RedisPool.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.redis; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Service; 5 | import redis.clients.jedis.ShardedJedis; 6 | import redis.clients.jedis.ShardedJedisPool; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * Created by jimin on 16/6/24. 12 | */ 13 | @Service("redisPool") 14 | @Slf4j 15 | public class RedisPool { 16 | 17 | /** 18 | * if use redis, should check these files: 19 | * (close injecting code, for no need to start redis-server every time) 20 | * 21 | * applicationContext.xml 22 | * RedisPool.java 23 | * SysCacheService.java 24 | */ 25 | @Resource(name = "shardedJedisPool") 26 | private ShardedJedisPool shardedJedisPool; 27 | 28 | public ShardedJedis instance() { 29 | return shardedJedisPool.getResource(); 30 | } 31 | 32 | public void safeClose(ShardedJedis shardedJedis) { 33 | try { 34 | if (shardedJedis != null) { 35 | shardedJedis.close(); 36 | } 37 | } catch (Exception e) { 38 | log.error("return redis resource exception", e); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/jobs/ExampleScheduledJob.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule.jobs; 2 | 3 | import com.app.mvc.schedule.AbstractScheduleJob; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.quartz.JobExecutionContext; 6 | import org.quartz.JobExecutionException; 7 | 8 | import java.text.SimpleDateFormat; 9 | import java.util.Calendar; 10 | 11 | /** 12 | * Created by jimin on 16/5/8. 13 | */ 14 | @Slf4j 15 | public class ExampleScheduledJob extends AbstractScheduleJob { 16 | 17 | @Override 18 | public void schedule(JobExecutionContext context) throws JobExecutionException { 19 | String jobName = context.getJobDetail().getKey().getName(); 20 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 21 | log.info("任务Key: {}, 正在执行,执行时间: {}", jobName, dateFormat.format(Calendar.getInstance().getTime())); 22 | try { 23 | Thread.sleep(10000); 24 | } catch (Throwable t) { 25 | 26 | } 27 | } 28 | 29 | @Override 30 | public String scheduleId() { 31 | return "schedule.test"; 32 | } 33 | 34 | @Override 35 | public String groupId() { 36 | return "group.test"; 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.File; 7 | import java.io.FileReader; 8 | import java.net.URL; 9 | 10 | /** 11 | * Created by jimin on 15/11/22. 12 | */ 13 | @Slf4j 14 | public class FileUtil { 15 | 16 | //读取 17 | public static String readFile(URL url) throws Exception { 18 | log.info("try to read file, {}", url.toString()); 19 | BufferedReader br = null; 20 | try { 21 | File file = new File(url.toURI()); 22 | br = new BufferedReader(new FileReader(file)); 23 | StringBuffer sb = new StringBuffer(); 24 | String line = null; 25 | while ((line = br.readLine()) != null) { 26 | sb.append(line); 27 | } 28 | log.info("read file succeed, {}", url.toString()); 29 | return sb.toString(); 30 | } catch (Exception e) { 31 | log.info("read file error, {}", url.toString(), e); 32 | throw e; 33 | } finally { 34 | if (br != null) { 35 | br.close(); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysRole.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/1/16. 14 | */ 15 | 16 | @ToString 17 | @Getter 18 | @Setter 19 | @Builder 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class SysRole { 23 | 24 | private Integer id; 25 | /** 26 | * 角色名称 27 | */ 28 | private String name; 29 | /** 30 | * 状态, 备用 31 | * 32 | * @see com.app.mvc.acl.enums.Status 33 | */ 34 | private int status; 35 | /** 36 | * 所属供应商 37 | */ 38 | private int supplierId; 39 | /** 40 | * 角色类型, 备用 41 | * 42 | * @see com.app.mvc.acl.enums.RoleType 43 | */ 44 | private int type; 45 | /** 46 | * 备注 47 | */ 48 | private String remark; 49 | /** 50 | * 操作者 51 | */ 52 | private String operator; 53 | /** 54 | * 操作者ip 55 | */ 56 | private String operateIp; 57 | /** 58 | * 操作时间 59 | */ 60 | private Date operateTime; 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/AclPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Length; 7 | 8 | import javax.validation.constraints.Max; 9 | import javax.validation.constraints.Min; 10 | import javax.validation.constraints.NotNull; 11 | 12 | @ToString 13 | @Getter 14 | @Setter 15 | public class AclPara { 16 | 17 | private Integer id; 18 | 19 | @Length(min = 2, max = 64, message = "权限名称长度需要在2~64个字之间") 20 | private String name; 21 | 22 | @NotNull(message = "必须选择权限模块") 23 | private Integer aclModuleId; 24 | 25 | @Length(min = 0, max = 128, message = "URL长度需要在128个字符以内") 26 | private String url; 27 | 28 | @NotNull(message = "必须指定类型") 29 | @Min(value = 0, message = "类型不合法") 30 | @Max(value = 2, message = "类型不合法") 31 | private Integer type; 32 | 33 | @NotNull(message = "必须指定状态") 34 | @Min(value = 0, message = "状态不合法") 35 | @Max(value = 1, message = "状态不合法") 36 | private Integer status; 37 | 38 | @NotNull(message = "展示顺序不能为空") 39 | private Integer seq; 40 | 41 | @Length(min = 0, max = 64, message = "备注长度需要在64个字以内") 42 | private String remark; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.security.MessageDigest; 6 | 7 | @Slf4j 8 | public class MD5Util { 9 | 10 | public final static String encrypt(String s) { 11 | char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; 12 | try { 13 | byte[] btInput = s.getBytes(); 14 | // 获得MD5摘要算法的 MessageDigest 对象 15 | MessageDigest mdInst = MessageDigest.getInstance("MD5"); 16 | // 使用指定的字节更新摘要 17 | mdInst.update(btInput); 18 | // 获得密文 19 | byte[] md = mdInst.digest(); 20 | // 把密文转换成十六进制的字符串形式 21 | int j = md.length; 22 | char str[] = new char[j * 2]; 23 | int k = 0; 24 | for (int i = 0; i < j; i++) { 25 | byte byte0 = md[i]; 26 | str[k++] = hexDigits[byte0 >>> 4 & 0xf]; 27 | str[k++] = hexDigits[byte0 & 0xf]; 28 | } 29 | return new String(str); 30 | } catch (Exception e) { 31 | log.error("generate md5 error, {}", s, e); 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/domain/Investment.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | import lombok.ToString; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by jimin on 16/3/7. 14 | */ 15 | @ToString 16 | @Getter 17 | @Setter 18 | @Builder 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | public class Investment { 22 | 23 | private Integer id; 24 | 25 | private String username; 26 | 27 | private String mobile; 28 | 29 | private String telephone; 30 | 31 | private String fax; 32 | 33 | private String area; 34 | 35 | private String sex; 36 | 37 | private String mail; 38 | 39 | private String qq; 40 | 41 | private String businessBrand; 42 | 43 | private String businessModel; 44 | 45 | private String venueName; 46 | 47 | private String businessSize; 48 | 49 | private String contractTime; 50 | 51 | private String investmentAmount; 52 | 53 | private String comment; 54 | 55 | private Date createTime; 56 | 57 | private int status; 58 | 59 | private String operator; 60 | 61 | private Date operateTime; 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/service/SysToolService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.service; 2 | 3 | import com.app.mvc.acl.dao.SysToolDao; 4 | import com.google.common.base.Preconditions; 5 | import org.springframework.stereotype.Service; 6 | 7 | import javax.annotation.Resource; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by jimin on 16/2/2. 13 | */ 14 | @Service 15 | public class SysToolService { 16 | 17 | @Resource 18 | private SysToolDao sysToolDao; 19 | @Resource 20 | private SysCoreService sysCoreService; 21 | 22 | /** 23 | * 判断url和rule是否满足db层的正则匹配 24 | */ 25 | public boolean checkRegexp(String url, String rule) { 26 | Preconditions.checkNotNull(url, "url不可以为空"); 27 | Preconditions.checkNotNull(rule, "rule不可以为空"); 28 | return sysToolDao.checkRegexp(url, rule) == 1; 29 | } 30 | 31 | public List executeSelect(String sql) { 32 | Preconditions.checkArgument(sysCoreService.isRootUser(), "该功能只有root用户可以执行"); 33 | return sysToolDao.executeSelect(sql); 34 | } 35 | 36 | public void executeUpdate(String sql) { 37 | Preconditions.checkArgument(sysCoreService.isRootUser(), "该功能只有root用户可以执行"); 38 | sysToolDao.executeUpdate(sql); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/PasswordUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import java.util.Date; 4 | import java.util.Random; 5 | 6 | /** 7 | * Created by jimin on 16/4/4. 8 | */ 9 | public class PasswordUtil { 10 | 11 | public final static String[] _NUM = { "2", "3", "4", "5", "6", "7", "8", "9" }; 12 | 13 | public final static String[] _WORD = { "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "A", 14 | "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "~", "!", "@", "#", "$", "%", "^", 15 | "&", "+", "?" }; 16 | 17 | public static String randomPassword() { 18 | StringBuffer password = new StringBuffer(); 19 | Random random = new Random(new Date().getTime()); 20 | Boolean flag = false; 21 | int length = random.nextInt(3) + 8; 22 | for (int i = 0; i < length; i++) { 23 | if (flag) { 24 | password.append(_NUM[random.nextInt(_NUM.length)]); 25 | } else { 26 | password.append(_WORD[random.nextInt(_WORD.length)]); 27 | } 28 | flag = !flag; 29 | } 30 | return password.toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/dao/SysUserDao.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.dao; 2 | 3 | import com.app.mvc.acl.domain.SysUser; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.common.DBRepository; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jimin on 16/1/18. 12 | */ 13 | @DBRepository 14 | public interface SysUserDao { 15 | 16 | void save(SysUser sysUser); 17 | 18 | void update(SysUser sysUser); 19 | 20 | void updatePassword(@Param("mail") String mail, @Param("password") String password); 21 | 22 | SysUser findById(@Param("id") int id); 23 | 24 | SysUser findByUsernameOrEmail(@Param("keyword") String keyword); 25 | 26 | List getPageByDeptId(@Param("deptId") int deptId, @Param("page") PageQuery page); 27 | 28 | int countByDeptId(@Param("deptId") int deptId); 29 | 30 | int countAvailableByDeptId(@Param("deptId") int deptId); 31 | 32 | int countByMail(@Param("mail") String mail, @Param("id") Integer id); 33 | 34 | int countByTelephone(@Param("telephone") String telephone, @Param("id") Integer id); 35 | 36 | List getByIdList(@Param("idList") List idList); 37 | 38 | List getBySupplierId(@Param("supplierId") int supplierId); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/test/TestCallable.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.test; 2 | 3 | import com.google.common.collect.Lists; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.ArrayBlockingQueue; 7 | import java.util.concurrent.Callable; 8 | import java.util.concurrent.ExecutorService; 9 | import java.util.concurrent.Future; 10 | import java.util.concurrent.ThreadPoolExecutor; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | /** 14 | * Created by jimin on 16/3/29. 15 | */ 16 | public class TestCallable { 17 | 18 | private static final ExecutorService threadPool = new ThreadPoolExecutor(2, 5, 120, TimeUnit.SECONDS, new ArrayBlockingQueue(100)); 19 | 20 | private static int flag = 0; 21 | 22 | // test future.get() 的NPE 23 | public static void main(String[] args) throws Exception { 24 | Future future = threadPool.submit(new Callable() { 25 | @Override 26 | public Long call() throws Exception { 27 | // return 1l; 28 | List list = Lists.newArrayList(); 29 | if (flag >= 0) { 30 | list = null; 31 | } 32 | return list.get(0); 33 | } 34 | }); 35 | System.out.println(future.get()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysAclModule.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import com.app.mvc.acl.enums.Status; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by jimin on 16/1/16. 15 | */ 16 | 17 | @ToString 18 | @Getter 19 | @Setter 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class SysAclModule { 24 | 25 | private Integer id; 26 | /** 27 | * 权限模块名称 28 | */ 29 | private String name; 30 | /** 31 | * 父权限模块 32 | */ 33 | private Integer parentId; 34 | /** 35 | * 权限模块层级 36 | */ 37 | private String level; 38 | /** 39 | * 权限模块状态 40 | * 41 | * @see com.app.mvc.acl.enums.Status 42 | */ 43 | private int status = Status.AVAILABLE.getCode(); 44 | /** 45 | * 权限模块在当前层级的序号 46 | */ 47 | private int seq; 48 | /** 49 | * 备注 50 | */ 51 | private String remark; 52 | /** 53 | * 操作者 54 | */ 55 | private String operator; 56 | /** 57 | * 操作者ip 58 | */ 59 | private String operateIp; 60 | /** 61 | * 操作时间 62 | */ 63 | private Date operateTime; 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/shortUrl/ShortUrlController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.shortUrl; 2 | 3 | import com.app.mvc.beans.JsonData; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | import javax.annotation.Resource; 12 | import javax.servlet.http.HttpServletResponse; 13 | 14 | /** 15 | * Created by jimin on 16/4/7. 16 | */ 17 | @Slf4j 18 | @Controller 19 | public class ShortUrlController { 20 | 21 | @Resource 22 | private ShortUrlService shortUrlService; 23 | 24 | @ResponseBody 25 | @RequestMapping("/gen") 26 | public JsonData generate(@RequestParam("url") String url) { 27 | return JsonData.success(shortUrlService.generate(url)); 28 | } 29 | 30 | @RequestMapping("/t/{url}") 31 | public void toOrigin(@PathVariable("url") String url, HttpServletResponse response) { 32 | try { 33 | response.sendRedirect(shortUrlService.getOriginUrlWithoutException(url)); 34 | } catch (Throwable t) { 35 | log.error("根据短链接跳转出现异常, url=" + url, t); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/FileInfoMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | origin_name as originName, 11 | name, 12 | operator, 13 | operate_time as operateTime, 14 | md5, 15 | size 16 | 17 | 18 | 25 | 26 | 32 | 33 | 34 | INSERT INTO file_info 35 | (origin_name, name, operator, operate_time, md5, size) 36 | VALUES (#{originName}, #{name}, #{operator}, now(), #{md5}, #{size}) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/spring-redis.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/webapp/assets/js/jquery.ui.touch-punch.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI Touch Punch 0.2.3 3 | * 4 | * Copyright 2011–2014, Dave Furfero 5 | * Dual licensed under the MIT or GPL Version 2 licenses. 6 | * 7 | * Depends: 8 | * jquery.ui.widget.js 9 | * jquery.ui.mouse.js 10 | */ 11 | !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery); -------------------------------------------------------------------------------- /src/main/resources/mapper/ProductMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | title, 11 | image, 12 | status 13 | 14 | 15 | 23 | 24 | 29 | 30 | 31 | INSERT INTO product 32 | (title, image, status, create_time, update_time) 33 | VALUES 34 | (#{title}, #{image}, 1, now(), now()) 35 | 36 | 37 | 38 | UPDATE product 39 | SET status = 0, 40 | update_time = now() 41 | WHERE id = #{id} 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/HttpInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.acl.util.RequestHolder; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.web.servlet.ModelAndView; 6 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * Created by Gaven8 on 16/7/12. 13 | */ 14 | @Slf4j 15 | public class HttpInterceptor extends HandlerInterceptorAdapter { 16 | 17 | @Override 18 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 19 | return true; 20 | } 21 | 22 | @Override 23 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 24 | // 正常返回时, 显式回收threadLocal里的信息 25 | removeThreadLocalInfo(); 26 | 27 | } 28 | 29 | @Override 30 | public void afterCompletion( 31 | HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) 32 | throws Exception { 33 | // 出异常时, 显式回收threadLocal里的信息 34 | removeThreadLocalInfo(); 35 | } 36 | 37 | private void removeThreadLocalInfo() { 38 | RequestHolder.remove(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysRoleUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO sys_role_user (role_id, user_id, operator, operate_ip) 10 | VALUES 11 | 12 | (#{cur.roleId}, #{cur.userId}, #{cur.operator}, #{cur.operateIp}) 13 | 14 | 15 | 16 | 21 | 22 | 27 | 28 | 29 | DELETE FROM sys_role_user 30 | WHERE role_id = #{roleId} 31 | 32 | 33 | 38 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/vo/UserPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.ToString; 6 | import org.hibernate.validator.constraints.Email; 7 | import org.hibernate.validator.constraints.Length; 8 | 9 | import javax.validation.constraints.Max; 10 | import javax.validation.constraints.Min; 11 | import javax.validation.constraints.NotNull; 12 | 13 | @ToString 14 | @Getter 15 | @Setter 16 | public class UserPara { 17 | 18 | private Integer id; 19 | 20 | @NotNull(message = "用户名不可以为空") 21 | @Length(min = 1, max = 64, message = "用户名长度需要在64个字以内") 22 | private String username; 23 | 24 | @NotNull(message = "电话不可以为空") 25 | @Length(min = 1, max = 32, message = "电话长度需要在32个字以内") 26 | private String telephone; 27 | 28 | @NotNull(message = "邮箱不允许为空") 29 | @Length(min = 10, max = 32, message = "邮箱长度需要在32个字以内") 30 | @Email(message = "邮箱格式不对") 31 | private String mail; 32 | 33 | private Integer supplierId; 34 | 35 | private String managedSupplierIds; 36 | 37 | @NotNull(message = "必须选择用户所在部门") 38 | private Integer deptId; 39 | 40 | /** 41 | * @see com.app.mvc.acl.enums.Status 42 | */ 43 | @NotNull(message = "必须指定用户的状态") 44 | @Min(value = -1, message = "用户状态不合法") 45 | @Max(value = 2, message = "用户状态不合法") 46 | private Integer status; 47 | private String remark; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.service; 2 | 3 | import com.app.mvc.acl.convert.BaseConvert; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.beans.PageResult; 6 | import com.app.mvc.business.dao.ProductDao; 7 | import com.app.mvc.business.domain.Product; 8 | import com.app.mvc.business.vo.ProductPara; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | /** 15 | * Created by jimin on 15/11/3. 16 | */ 17 | @Service 18 | public class ProductService { 19 | 20 | @Resource 21 | private ProductDao productDao; 22 | 23 | public PageResult getPage(PageQuery page) { 24 | BaseConvert.checkPara(page); 25 | int count = productDao.countValid(); 26 | if (count > 0) { 27 | List list = productDao.getValidProductList(page); 28 | return PageResult.builder().data(list).total(count).build(); 29 | } 30 | return PageResult.builder().build(); 31 | } 32 | 33 | public void save(ProductPara para) { 34 | BaseConvert.checkPara(para); 35 | Product product = Product.builder().id(para.getId()).title(para.getTitle()).image(para.getImage()).build(); 36 | productDao.save(product); 37 | } 38 | 39 | public void delete(int id) { 40 | productDao.invalid(id); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/webapp/assets/css/bootstrap-duallistbox.min.css: -------------------------------------------------------------------------------- 1 | .bootstrap-duallistbox-container .buttons{width:100%;margin-bottom:-1px}.bootstrap-duallistbox-container label{display:block}.bootstrap-duallistbox-container .info{display:inline-block;margin-bottom:5px;font-size:11px}.bootstrap-duallistbox-container .clear1,.bootstrap-duallistbox-container .clear2{display:none;font-size:10px}.bootstrap-duallistbox-container .box1.filtered .clear1,.bootstrap-duallistbox-container .box2.filtered .clear2{display:inline-block}.bootstrap-duallistbox-container .move,.bootstrap-duallistbox-container .remove{width:60%}.bootstrap-duallistbox-container .btn-group .btn{border-bottom-left-radius:0;border-bottom-right-radius:0}.bootstrap-duallistbox-container .moveall,.bootstrap-duallistbox-container .removeall{width:40%}.bootstrap-duallistbox-container.bs2compatible .btn-group>.btn+.btn{margin-left:0}.bootstrap-duallistbox-container select{border-top-left-radius:0;border-top-right-radius:0;width:100%;height:300px;padding:0}.bootstrap-duallistbox-container .filter{display:inline-block;width:100%;height:31px;margin:0 0 5px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bootstrap-duallistbox-container .filter.placeholder{color:#aaa}.bootstrap-duallistbox-container.moveonselect .move,.bootstrap-duallistbox-container.moveonselect .remove{display:none}.bootstrap-duallistbox-container.moveonselect .moveall,.bootstrap-duallistbox-container.moveonselect .removeall{width:100%} -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/enums/LogType.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.enums; 2 | 3 | import com.app.mvc.acl.domain.SysAcl; 4 | import com.app.mvc.acl.domain.SysAclModule; 5 | import com.app.mvc.acl.domain.SysDept; 6 | import com.app.mvc.acl.domain.SysRole; 7 | import com.app.mvc.acl.domain.SysUser; 8 | import lombok.Getter; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by jimin on 16/1/18. 14 | */ 15 | @Getter 16 | public enum LogType { 17 | 18 | ACL(1, SysAcl.class), 19 | ACL_MODULE(2, SysAclModule.class), 20 | USER(3, SysUser.class), 21 | DEPT(4, SysDept.class), 22 | ROLE(5, SysRole.class), 23 | ROLE_USER(6, List.class), 24 | ROLE_ACL(7, List.class); 25 | 26 | private int code; 27 | private Class clazz; 28 | 29 | LogType(int code, Class clazz) { 30 | this.code = code; 31 | this.clazz = clazz; 32 | } 33 | 34 | public static LogType codeOf(int code) { 35 | switch (code) { 36 | case 1: 37 | return ACL; 38 | case 2: 39 | return ACL_MODULE; 40 | case 3: 41 | return USER; 42 | case 4: 43 | return DEPT; 44 | case 5: 45 | return ROLE; 46 | case 6: 47 | return ROLE_USER; 48 | case 7: 49 | return ROLE_ACL; 50 | 51 | default: 52 | throw new RuntimeException("unknown log type, code :" + code); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/controller/SysToolController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.controller; 2 | 3 | import com.app.mvc.acl.service.SysToolService; 4 | import com.app.mvc.beans.JsonData; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | import javax.annotation.Resource; 12 | 13 | /** 14 | * Created by jimin on 16/2/2. 15 | */ 16 | @Slf4j 17 | @Controller 18 | @RequestMapping("/sys/tool") 19 | public class SysToolController { 20 | 21 | @Resource 22 | private SysToolService sysToolService; 23 | 24 | @ResponseBody 25 | @RequestMapping(value = "/regexp.json") 26 | public JsonData regexp(@RequestParam("url") String url, @RequestParam("rule") String rule) { 27 | return JsonData.success(sysToolService.checkRegexp(url, rule)); 28 | } 29 | 30 | @ResponseBody 31 | @RequestMapping(value = "/select.json") 32 | public JsonData select(@RequestParam("sql") String sql) { 33 | return JsonData.success(sysToolService.executeSelect(sql)); 34 | } 35 | 36 | @ResponseBody 37 | @RequestMapping(value = "/update.json") 38 | public JsonData update(@RequestParam("sql") String sql) { 39 | sysToolService.executeUpdate(sql); 40 | return JsonData.success(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/beans/JsonData.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.beans; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class JsonData { 7 | 8 | private final boolean ret; 9 | private String msg; 10 | private Object data; 11 | 12 | private JsonData(boolean ret) { 13 | this.ret = ret; 14 | } 15 | 16 | public static JsonData error(String message) { 17 | JsonData result = new JsonData(false); 18 | result.msg = message; 19 | return result; 20 | } 21 | 22 | public static JsonData success(Object object, String msg) { 23 | JsonData result = new JsonData(true); 24 | result.data = object; 25 | result.msg = msg; 26 | return result; 27 | } 28 | 29 | public Map toMap() { 30 | HashMap result = new HashMap(); 31 | result.put("ret", ret); 32 | result.put("msg", msg); 33 | result.put("data", data); 34 | return result; 35 | } 36 | 37 | public static JsonData success(Object object) { 38 | return success(object, null); 39 | } 40 | 41 | public static JsonData success() { 42 | return success(null, null); 43 | } 44 | 45 | public boolean getRet() { 46 | return ret; 47 | } 48 | 49 | public String getMsg() { 50 | return msg; 51 | } 52 | 53 | public Object getData() { 54 | return data; 55 | } 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysRoleAclMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | INSERT INTO sys_role_acl (role_id, acl_id, operator, operate_ip) 10 | VALUES 11 | 12 | (#{cur.roleId}, #{cur.aclId}, #{cur.operator}, #{cur.operateIp}) 13 | 14 | 15 | 16 | 21 | 22 | 30 | 31 | 32 | DELETE FROM sys_role_acl 33 | WHERE role_id = #{roleId} 34 | 35 | 36 | 41 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/InvestmentController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.controller; 2 | 3 | import com.app.mvc.beans.JsonData; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.business.service.InvestmentService; 6 | import com.app.mvc.business.vo.InvestmentPara; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import javax.annotation.Resource; 14 | 15 | /** 16 | * Created by jimin on 16/3/8. 17 | */ 18 | @Slf4j 19 | @Controller 20 | public class InvestmentController { 21 | 22 | @Resource 23 | private InvestmentService investmentService; 24 | 25 | @ResponseBody 26 | @RequestMapping("/investment/save.json") 27 | public JsonData save(InvestmentPara para) { 28 | investmentService.save(para); 29 | return JsonData.success(); 30 | } 31 | 32 | @ResponseBody 33 | @RequestMapping("/admin/investment/list.json") 34 | public JsonData list(PageQuery page) { 35 | return JsonData.success(investmentService.getPage(page)); 36 | } 37 | 38 | @ResponseBody 39 | @RequestMapping("/admin/investment/invalid.json") 40 | public JsonData invalid(@RequestParam("id") int id) { 41 | investmentService.invalid(id); 42 | return JsonData.success(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/proxy/checker/DefaultUrlConnectionChecker.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.proxy.checker; 2 | 3 | import com.app.mvc.proxy.UrlConnectionChecker; 4 | import com.app.mvc.util.HttpUtil; 5 | import org.apache.http.client.HttpClient; 6 | import org.apache.http.client.methods.HttpGet; 7 | import org.apache.http.client.methods.HttpPost; 8 | 9 | /** 10 | * Created by jimin on 16/5/4. 11 | */ 12 | public class DefaultUrlConnectionChecker implements UrlConnectionChecker { 13 | 14 | private String url; 15 | 16 | private HttpClient httpClient = null; 17 | 18 | public DefaultUrlConnectionChecker(String url) { 19 | this.url = url; 20 | } 21 | 22 | public DefaultUrlConnectionChecker(String url, HttpClient httpClient) { 23 | this.url = url; 24 | this.httpClient = httpClient; 25 | } 26 | 27 | @Override 28 | public String url() { 29 | return url; 30 | } 31 | 32 | @Override 33 | public HttpPost httpPost() { 34 | return new HttpPost(url); 35 | } 36 | 37 | @Override 38 | public HttpGet httpGet() { 39 | return new HttpGet(url); 40 | } 41 | 42 | @Override 43 | public HttpClient httpClient() { 44 | if (httpClient == null) { 45 | return HttpUtil.defaultClient(); 46 | } 47 | return httpClient; 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/Base64Util.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | 5 | /** 6 | * 统一项目中base64算法的使用。可避免项目中引用不同三方库去实现相同代码 7 | * Created by jimin on 16/2/10 8 | */ 9 | public class Base64Util { 10 | 11 | /** 12 | * encode for 13 | * byte - > byte using base64 14 | * 15 | * @param binaryData 16 | * @return 17 | */ 18 | public static byte[] encodeByte(final byte[] binaryData) { 19 | return Base64.encodeBase64(binaryData, false); 20 | } 21 | 22 | /** 23 | * encode for 24 | * byte - > string using base64 25 | * 26 | * @param binaryData 27 | * @return 28 | */ 29 | public static String encode(final byte[] binaryData) { 30 | return Base64.encodeBase64String(binaryData); 31 | } 32 | 33 | /** 34 | * decode for 35 | * string -> byte using base64 36 | * 37 | * @param base64String 38 | * @return 39 | */ 40 | public static byte[] decode(final String base64String) { 41 | return new Base64().decode(base64String); 42 | } 43 | 44 | /** 45 | * decode for 46 | * byte -> byte using base64 47 | * 48 | * @param base64Data 49 | * @return 50 | */ 51 | public static byte[] decode(final byte[] base64Data) { 52 | return new Base64().decode(base64Data); 53 | } 54 | 55 | public static String decodeStr(final String base64String) { 56 | return new String(decode(base64String)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysAcl.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by jimin on 16/1/16. 15 | */ 16 | 17 | @ToString 18 | @Getter 19 | @Setter 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @EqualsAndHashCode(of = { "id" }) 24 | public class SysAcl { 25 | 26 | private Integer id; 27 | /** 28 | * 权限点标识 29 | */ 30 | private String code; 31 | /** 32 | * 权限点名称 33 | */ 34 | private String name; 35 | /** 36 | * 权限点所属权限模块 37 | */ 38 | private int aclModuleId; 39 | /** 40 | * 权限点对应url 41 | */ 42 | private String url; 43 | /** 44 | * 权限点类型 45 | * 46 | * @see com.app.mvc.acl.enums.AclType 47 | */ 48 | private int type; 49 | /** 50 | * 权限点状态 51 | * 52 | * @see com.app.mvc.acl.enums.Status 53 | */ 54 | private int status; 55 | /** 56 | * 权限点在当前权限模块的序号 57 | */ 58 | private int seq; 59 | /** 60 | * 备注 61 | */ 62 | private String remark; 63 | /** 64 | * 操作者 65 | */ 66 | private String operator; 67 | /** 68 | * 操作者ip 69 | */ 70 | private String operateIp; 71 | /** 72 | * 操作时间 73 | */ 74 | private Date operateTime; 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/NasdaqParser.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import com.google.common.base.Joiner; 4 | import com.google.common.collect.Lists; 5 | import org.jsoup.Jsoup; 6 | import org.jsoup.nodes.Document; 7 | import org.jsoup.nodes.Element; 8 | import org.jsoup.select.Elements; 9 | 10 | import java.util.List; 11 | 12 | public class NasdaqParser { 13 | 14 | public static void main(String[] args) throws Exception { 15 | String symbol = "PG"; 16 | String url = "http://vip.stock.finance.sina.com.cn/usstock/summary.php?s=PG"; 17 | Document doc = Jsoup.connect(url).get(); 18 | // 找到指定id的table及里面的body 19 | Element tbody = doc.select("#quotes_content_left_dividendhistoryGrid tbody").first(); 20 | // 遍历tbody里的每个tr 21 | for(Element tr : tbody.children()) { 22 | // 获取tr下面td列表 23 | Elements tdList = tr.children(); 24 | List line = Lists.newArrayList(); 25 | // 遍历每个td 26 | for (Element td : tdList) { 27 | // 有的td下面包含span 28 | Elements span = td.select("span"); 29 | if (span == null || span.size() == 0) { 30 | line.add(td.text()); 31 | } else { 32 | line.add(span.html()); 33 | } 34 | } 35 | // line里的数据一次为 Ex/Eff Date, Type, Cash Amount, Declaration Date, Record Date, Payment Date 36 | System.out.println(Joiner.on(",").join(line)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/domain/SysUser.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.EqualsAndHashCode; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by jimin on 16/1/16. 15 | */ 16 | 17 | @ToString 18 | @Getter 19 | @Setter 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @EqualsAndHashCode(of = { "id" }) 24 | public class SysUser { 25 | 26 | private Integer id; 27 | /** 28 | * 用户名 29 | */ 30 | private String username; 31 | /** 32 | * 密码(加密后) 33 | */ 34 | private String password; 35 | /** 36 | * 电话 37 | */ 38 | private String telephone; 39 | /** 40 | * 邮箱 41 | */ 42 | private String mail; 43 | /** 44 | * 描述 45 | */ 46 | private String remark; 47 | /** 48 | * 所属部门 49 | */ 50 | private int deptId; 51 | /** 52 | * 状态 53 | * 54 | * @see com.app.mvc.acl.enums.Status 55 | */ 56 | private int status; 57 | /** 58 | * 所属供应商 59 | */ 60 | private int supplierId; 61 | /** 62 | * 管理的供应商 63 | */ 64 | private String managedSupplierIds; 65 | /** 66 | * 操作者 67 | */ 68 | private String operator; 69 | /** 70 | * 操作者ip 71 | */ 72 | private String operateIp; 73 | /** 74 | * 操作时间 75 | */ 76 | private Date operateTime; 77 | } 78 | -------------------------------------------------------------------------------- /Untitled Diagram.xml: -------------------------------------------------------------------------------- 1 | 5ZlZb+M2EMc/jR9r6Lb1uHGOFmiBRVO0jwJN0RKxFClQlI9++g4tSpZMJnAWduHN+iERZ3iI8/95eHgWrqr9i0R1+YfICZsFXr6fhY+zIPCjMIJ/2nLoLFGadoZC0txUOhle6b/EGD1jbWlOmklFJQRTtJ4aseCcYDWxISnFblptI9h01BoVxDK8YsRs6z80V6Wx+p53cvxKaFGaoZexcawR/lZI0XIz3iwIN8dP565Q35ep35QoF7uRKXyahSsphOqeqv2KMB3bPmxdu+c3vMN7S8LVJQ0WXpIkizjBy2i9TkP8i+lhi1hL+ikcX1Qd+uBAD6ADFB52JVXktUZYe3aAAthKVTEo+fB4jAPRI3lQGqaqC1hUFPcOJcW3Ic664UZw9YwqyjQ+fxOZI46M2bDiR0PDlWBCgokLrt9pQxnrTRB9z0vSY592ZPqpEqnIfmQykXohoiJKHqCK8QZLo9ph4KEr706MxD0i5QiPwYgMl8XQ90kbeDDyXChVYEn1xBWRtaQgTpAwGPwhp1t4LPTjQ9tQTpqmd8F4I6+jgflau2vfIRNauouYMN/IrrGLlWOnZnKOr9SHwYm8KTgwlAVOkDjAGYxXBSe2wFmJqmo5VQdL2IlCOWrKQbuRqB8KOkNrwr6KhioqOPgw0dSCQ8eTQg7+/azCWiglqlGFL4wW2qFE3TFU65et9oVejOZis6GYzNuGyKb7a2E3Ju3CXHOGyvPxc520EsZTOqLIpiNKXFnlBmwkNhttA+EHhewM8UrkFmJ9YY74wVGC2izrRshg+ddy3zVWySKZYuWHl2EV3wCrhYXVn6SpBXeuVC8Q1vrngEqaKGTFcc73TdR5ogo8m6h46SAqugFRSztRwcwkYq6dDISqIJWe+aWbn58ktTXdNCG7dcHLqiFUmfHdO5T+YgJl6Ehzsf8/QZlaUD7SgionlI9kS5io36PyM1Gms53gWS1JBeeTJutsdw7X4nzjvgzsNTRywLW8AVz9aXNE118ElxymXhwcgK20RBB/pMibh77PQxhuJZxf5gpejf8gqSs63/inNl2uU2Gc3IIu++bnN76RCNRusWol+TywYMExqdUkH905KnEanqFinxFDVyK6xWbet2+eXphYO1e5r0gqDrm/1Fe3nzwJDVwVEA2SUT0IJ/d+Towif4KW77p+SG20ett10QottJ74lkrB9T7JSdiXnZ79OxebV8PrXPaqwYjMCxgcds5afUV5K9omwwfM3uPxZji4cf1+/JHpZ2hxjVR2tur5YWzz5jpF3uK6y7fvQp8pRxw7l7uJ+g2EppnDoQm28XPSSjEl6C3tnWR9Zx6y5Hnndn1C+n1loCScHuH8ZWoTETuI8D9MBBRPP64dfaNfMMOn/wA= -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/vo/InvestmentPara.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.vo; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * Created by jimin on 16/3/8. 10 | */ 11 | @Getter 12 | @Setter 13 | public class InvestmentPara { 14 | 15 | /** 16 | * 姓名 17 | */ 18 | @NotNull(message = "姓名不可以为空") 19 | private String username; 20 | /** 21 | * 手机号码 22 | */ 23 | @NotNull(message = "手机号码不可以为空") 24 | private String mobile; 25 | /** 26 | * 座机号码 27 | */ 28 | private String telephone; 29 | /** 30 | * 传真 31 | */ 32 | private String fax; 33 | /** 34 | * 所在地区 35 | */ 36 | @NotNull(message = "所在地区不可以为空") 37 | private String area; 38 | /** 39 | * 性别 40 | */ 41 | private String sex; 42 | /** 43 | * mail 44 | */ 45 | private String mail; 46 | /** 47 | * QQ 48 | */ 49 | private String qq; 50 | /** 51 | * 经营品牌 52 | */ 53 | @NotNull(message = "经营品牌不可以为空") 54 | private String businessBrand; 55 | /** 56 | * 经营模式 57 | */ 58 | @NotNull(message = "经营模式不可以为空") 59 | private String businessModel; 60 | /** 61 | * 场馆名称 62 | */ 63 | private String venueName; 64 | /** 65 | * 经营面积 66 | */ 67 | private String businessSize; 68 | /** 69 | * 合约时间 70 | */ 71 | private String contractTime; 72 | /** 73 | * 投资金额 74 | */ 75 | private String investmentAmount; 76 | /** 77 | * 备注 78 | */ 79 | private String comment; 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/SpringExceptionResolver.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.beans.JsonData; 4 | import com.app.mvc.exception.NotFoundException; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.servlet.HandlerExceptionResolver; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | @Slf4j 13 | public class SpringExceptionResolver implements HandlerExceptionResolver { 14 | 15 | private static final String JSON_URI = ".json"; 16 | 17 | @Override 18 | public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { 19 | 20 | String url = request.getRequestURL().toString(); 21 | ModelAndView mv; 22 | String msg = "system error"; 23 | 24 | if (url.endsWith(JSON_URI)) { 25 | if (ex instanceof RuntimeException) { 26 | JsonData result = JsonData.error(ex.getMessage()); 27 | mv = new ModelAndView("jsonView", result.toMap()); 28 | } else { 29 | JsonData result = JsonData.error(msg); 30 | mv = new ModelAndView("jsonView", result.toMap()); 31 | } 32 | } else { 33 | log.error("系统错误", ex); 34 | JsonData result = JsonData.error(msg); 35 | mv = new ModelAndView("exception", result.toMap()); 36 | } 37 | 38 | log.error("SpringMVCException, url=" + url + ", msg=" + ex.getMessage(), ex); 39 | return mv; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/service/TestService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.service; 2 | 3 | import com.google.common.collect.Maps; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.concurrent.ArrayBlockingQueue; 8 | import java.util.concurrent.ConcurrentMap; 9 | import java.util.concurrent.ThreadPoolExecutor; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * Created by jimin on 16/3/25. 14 | */ 15 | @Slf4j 16 | @Service 17 | public class TestService { 18 | private ConcurrentMap threadPoolExecutorMap = Maps.newConcurrentMap(); 19 | 20 | public void start() { 21 | while (true) { 22 | getThreadPool("123").execute(new Runnable() { 23 | @Override 24 | public void run() { 25 | log.info(System.currentTimeMillis() + ""); 26 | } 27 | }); 28 | try { 29 | Thread.currentThread().sleep(10000); 30 | } catch (Throwable t) { 31 | log.error("e", t); 32 | } 33 | } 34 | } 35 | 36 | public ThreadPoolExecutor getThreadPool(String key) { 37 | if (threadPoolExecutorMap.containsKey(key)) { 38 | return threadPoolExecutorMap.get(key); 39 | } 40 | log.info("init " + key); 41 | 42 | threadPoolExecutorMap.put(key, 43 | new ThreadPoolExecutor(2, 5, 120, TimeUnit.HOURS, new ArrayBlockingQueue(10), new ThreadPoolExecutor.DiscardOldestPolicy())); 44 | return threadPoolExecutorMap.get(key); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.controller; 2 | 3 | import com.app.mvc.beans.JsonData; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.business.service.ProductService; 6 | import com.app.mvc.business.vo.ProductPara; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.ResponseBody; 14 | 15 | /** 16 | * Created by jimin on 15/10/27. 17 | */ 18 | @Slf4j 19 | @Controller 20 | @RequestMapping("/product") 21 | public class ProductController { 22 | 23 | @Autowired 24 | private ProductService productService; 25 | 26 | @ResponseBody 27 | @RequestMapping(value = "page.json", method = RequestMethod.GET) 28 | public JsonData productQuery(PageQuery pageQuery) throws Exception { 29 | return JsonData.success(productService.getPage(pageQuery)); 30 | } 31 | 32 | @ResponseBody 33 | @RequestMapping(value = "save.json") 34 | public JsonData save(ProductPara para) throws Exception { 35 | productService.save(para); 36 | return JsonData.success(); 37 | } 38 | 39 | @ResponseBody 40 | @RequestMapping(value = "delete.json") 41 | public JsonData delete(@RequestParam("id") int id) throws Exception { 42 | productService.delete(id); 43 | return JsonData.success(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/acl/config/LogTypeServiceConfig.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.acl.config; 2 | 3 | import com.app.mvc.acl.enums.LogType; 4 | import com.app.mvc.acl.service.SysAclModuleService; 5 | import com.app.mvc.acl.service.SysAclService; 6 | import com.app.mvc.acl.service.SysDeptService; 7 | import com.app.mvc.acl.service.SysRoleAclService; 8 | import com.app.mvc.acl.service.SysRoleService; 9 | import com.app.mvc.acl.service.SysRoleUserService; 10 | import com.app.mvc.acl.service.SysService; 11 | import com.app.mvc.acl.service.SysUserService; 12 | import com.app.mvc.common.SpringHelper; 13 | import com.google.common.collect.ImmutableMap; 14 | 15 | import java.util.Map; 16 | 17 | /** 18 | * Created by jimin on 16/1/24. 19 | */ 20 | public class LogTypeServiceConfig { 21 | 22 | private final static Map logTypeServiceMap = ImmutableMap.builder() 23 | .put(LogType.ACL.getCode(), SpringHelper.popBean(SysAclService.class)) 24 | .put(LogType.ACL_MODULE.getCode(), SpringHelper.popBean(SysAclModuleService.class)) 25 | .put(LogType.DEPT.getCode(), SpringHelper.popBean(SysDeptService.class)) 26 | .put(LogType.USER.getCode(), SpringHelper.popBean(SysUserService.class)) 27 | .put(LogType.ROLE.getCode(), SpringHelper.popBean(SysRoleService.class)) 28 | .put(LogType.ROLE_USER.getCode(), SpringHelper.popBean(SysRoleUserService.class)) 29 | .put(LogType.ROLE_ACL.getCode(), SpringHelper.popBean(SysRoleAclService.class)).build(); 30 | 31 | public static SysService getByLogTypeCode(int code) { 32 | return logTypeServiceMap.get(code); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/HashUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.security.MessageDigest; 6 | import java.security.NoSuchAlgorithmException; 7 | 8 | /** 9 | * Created by jimin on 15/12/11. 10 | */ 11 | @Slf4j 12 | public class HashUtil { 13 | 14 | public HashUtil() { 15 | } 16 | 17 | public static byte[] hash(String algorithm, byte[] bytes) throws NoSuchAlgorithmException { 18 | if (algorithm != null && bytes != null) { 19 | MessageDigest md = MessageDigest.getInstance(algorithm.toUpperCase()); 20 | return md.digest(bytes); 21 | } else { 22 | return null; 23 | } 24 | } 25 | 26 | public static byte[] hash(String algorithm, String str) throws NoSuchAlgorithmException { 27 | return str == null ? null : hash(algorithm, str.getBytes()); 28 | } 29 | 30 | public static byte[] hashMD5(byte[] bytes) { 31 | try { 32 | return hash("MD5", bytes); 33 | } catch (NoSuchAlgorithmException var2) { 34 | log.error("The algorithm is not available in the caller\'s environment.", var2); 35 | return null; 36 | } 37 | } 38 | 39 | public static byte[] hashMD5(String str) { 40 | return str == null ? null : hashMD5(str.getBytes()); 41 | } 42 | 43 | public static byte[] hashSHA1(String str) { 44 | try { 45 | return hash("SHA1", str); 46 | } catch (NoSuchAlgorithmException var2) { 47 | log.error("The algorithm is not available in the caller\'s environment.", var2); 48 | return null; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/shortUrl/ShortUrlService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.shortUrl; 2 | 3 | import com.app.mvc.acl.enums.Status; 4 | import org.springframework.stereotype.Service; 5 | 6 | import javax.annotation.Resource; 7 | 8 | /** 9 | * Created by jimin on 16/4/7. 10 | */ 11 | @Service 12 | public class ShortUrlService { 13 | 14 | @Resource 15 | private ShortUrlDao shortUrlDao; 16 | 17 | public String generate(String url) { 18 | String newUrl = ShortUrlUtil.generate(url); 19 | ShortUrl shortUrl = shortUrlDao.findByNewUrl(url); 20 | if (shortUrl != null) { 21 | return shortUrl.getCurrent(); 22 | } 23 | shortUrl = ShortUrl.builder().origin(url).current(newUrl).status(Status.AVAILABLE.getCode()).build(); 24 | shortUrlDao.save(shortUrl); 25 | return newUrl; 26 | } 27 | 28 | public String getOriginUrl(String url) { 29 | ShortUrl shortUrl = shortUrlDao.findByNewUrl(url); 30 | if (shortUrl == null) { 31 | throw new RuntimeException("未查到该短链接"); 32 | } 33 | if (shortUrl.getStatus() != Status.AVAILABLE.getCode()) { 34 | throw new RuntimeException("该短链接已失效"); 35 | } 36 | if (shortUrl.getInvalidTime() != null && shortUrl.getInvalidTime().getTime() < System.currentTimeMillis()) { 37 | throw new RuntimeException("该短链接已过期"); 38 | } 39 | return shortUrl.getOrigin(); 40 | } 41 | 42 | public String getOriginUrlWithoutException(String url) { 43 | try { 44 | return getOriginUrl(url); 45 | } catch (Throwable t) { 46 | return "/index.jsp"; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/business/controller/ArticleController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.business.controller; 2 | 3 | import com.app.mvc.beans.JsonData; 4 | import com.app.mvc.beans.PageQuery; 5 | import com.app.mvc.business.service.ArticleService; 6 | import com.app.mvc.business.vo.ArticlePara; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | import org.springframework.web.bind.annotation.ResponseBody; 12 | 13 | import javax.annotation.Resource; 14 | 15 | /** 16 | * Created by jimin on 16/3/8. 17 | */ 18 | @Slf4j 19 | @Controller 20 | public class ArticleController { 21 | 22 | @Resource 23 | private ArticleService articleService; 24 | 25 | @ResponseBody 26 | @RequestMapping("/admin/article/save.json") 27 | public JsonData save(ArticlePara para) { 28 | articleService.save(para); 29 | return JsonData.success(); 30 | } 31 | 32 | @ResponseBody 33 | @RequestMapping("/admin/article/update.json") 34 | public JsonData update(ArticlePara para) { 35 | articleService.update(para); 36 | return JsonData.success(); 37 | } 38 | 39 | @ResponseBody 40 | @RequestMapping("/article/read.json") 41 | public JsonData read(@RequestParam("id") int id) { 42 | articleService.incrReadTime(id); 43 | return JsonData.success(); 44 | } 45 | 46 | @ResponseBody 47 | @RequestMapping("/article/list.json") 48 | public JsonData read(PageQuery page) { 49 | return JsonData.success(articleService.getPage(page)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/captcha/CaptchaController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.captcha; 2 | 3 | import com.google.common.base.Throwables; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | import javax.annotation.Resource; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | /** 13 | * Created by jimin on 16/3/9. 14 | */ 15 | @Slf4j 16 | @Controller 17 | public class CaptchaController { 18 | 19 | @Resource 20 | private CaptchaService captchaService; 21 | 22 | @RequestMapping("/captcha") 23 | public void generate(HttpServletRequest request, HttpServletResponse response) throws Exception { 24 | // 设置响应的类型格式为图片格式 25 | response.setContentType("image/jpeg"); 26 | //禁止图像缓存。 27 | response.setHeader("Pragma", "no-cache"); 28 | response.setHeader("Cache-Control", "no-cache"); 29 | response.setDateHeader("Expires", 0); 30 | 31 | Captcha captcha = new Captcha(120, 40, 5, 30); 32 | String sessionId = request.getSession().getId(); 33 | try { 34 | captchaService.saveCaptchaCode(captcha.getCode(), sessionId); 35 | } catch (Throwable t) { 36 | log.error("保存验证码出错, 不影响生成的验证码, 但本次验证也会出错, code:{}, sessionId:{}", captcha.getCode(), sessionId, t); 37 | } 38 | try { 39 | captcha.write(response.getOutputStream()); 40 | } catch (Throwable t) { 41 | log.error("验证码返回出现异常, code:{}, sessionId:{}", captcha.getCode(), sessionId, t); 42 | throw Throwables.propagate(t); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/AbstractScheduleJob.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import com.app.mvc.common.SpringHelper; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.quartz.Job; 6 | import org.quartz.JobExecutionContext; 7 | import org.quartz.JobExecutionException; 8 | 9 | /** 10 | * Created by jimin on 16/5/8. 11 | */ 12 | @Slf4j 13 | public abstract class AbstractScheduleJob implements Job { 14 | 15 | private static ScheduleExecuteResultDao scheduleExecuteResultDao = SpringHelper.popBean(ScheduleExecuteResultDao.class); 16 | 17 | @Override 18 | public void execute(JobExecutionContext context) throws JobExecutionException { 19 | String scheduleId = groupId() + "_" + scheduleId(); 20 | log.info("定时任务[{}]开始执行", scheduleId); 21 | ScheduleExecuteResult scheduleExecuteResult = ScheduleExecuteResult.builder().scheduleId(scheduleId).status(ScheduleExecuteStatus.RUNNING.getCode()) 22 | .build(); 23 | scheduleExecuteResultDao.save(scheduleExecuteResult); 24 | try { 25 | schedule(context); 26 | scheduleExecuteResult.setStatus(ScheduleExecuteStatus.FINISHED.getCode()); 27 | } catch (Throwable t) { 28 | scheduleExecuteResult.setStatus(ScheduleExecuteStatus.EXCEPTION.getCode()); 29 | log.error("定时任务[" + scheduleId + "]执行出现异常", t); 30 | } 31 | scheduleExecuteResultDao.update(scheduleExecuteResult); 32 | log.info("定时任务[{}]执行结束", scheduleId); 33 | } 34 | 35 | public abstract void schedule(JobExecutionContext context) throws JobExecutionException; 36 | 37 | public abstract String scheduleId(); 38 | 39 | public abstract String groupId(); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/ServiceDegarding.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.config.GlobalConfig; 4 | import com.app.mvc.config.GlobalConfigKey; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | import java.util.Map; 9 | import java.util.Random; 10 | import java.util.Set; 11 | 12 | /** 13 | * Created by jimin on 16/4/23. 14 | */ 15 | @Slf4j 16 | public class ServiceDegarding { 17 | 18 | public static boolean isAllowed(String url) { 19 | // 是否为不允许访问的url 20 | Set notAllowedUrlSet = GlobalConfig.getSetValue(GlobalConfigKey.NOT_ALLOWED_URLS); 21 | if (notAllowedUrlSet.contains(url)) { 22 | log.info("service degarding, not allowed to visit url:{}", url); 23 | return false; 24 | } 25 | // 是否为切指定流量访问的url 26 | Map percentAllowedUrlMap = GlobalConfig.getMapValue(GlobalConfigKey.PERCENT_ALLOWED_URLS); 27 | if (percentAllowedUrlMap.containsKey(url)) { 28 | String v = percentAllowedUrlMap.get(url); 29 | int percent = 10; // 如果设置了切部分流量, 默认开放10%的流量, 配置出错时使用这个值 30 | if (!StringUtils.isNumeric(v)) { 31 | log.error("service degarding with percent setting error, url:{}, v:{}", v); 32 | } else { 33 | percent = Integer.parseInt(v); 34 | } 35 | percent = Math.min(percent, 100); 36 | int random = Math.abs(new Random().nextInt()) % 100; 37 | log.info("service degarding with percent, url:{}, percent;{}, random:{}", url, percent, random); 38 | return random < percent; 39 | } 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/captcha/CaptchaImgFont.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.captcha; 2 | 3 | import com.app.mvc.util.FileUtil; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import java.awt.*; 7 | import java.io.ByteArrayInputStream; 8 | import java.net.URL; 9 | 10 | /** 11 | * Created by jimin on 15/11/21. 12 | */ 13 | @Slf4j 14 | public class CaptchaImgFont { 15 | 16 | // 常量,由于太长,放到文件中,服务启动时加载到内存中 17 | public static String fontStr = null; 18 | 19 | public Font getFont(int fontHeight) { 20 | try { 21 | Font baseFont = Font.createFont(Font.TRUETYPE_FONT, new ByteArrayInputStream(hex2byte(fontStr))); 22 | return baseFont.deriveFont(Font.PLAIN, fontHeight); 23 | } catch (Exception e) { 24 | return new Font("Arial", Font.PLAIN, fontHeight); 25 | } 26 | } 27 | 28 | private byte[] hex2byte(String str) { 29 | if (str == null) 30 | return null; 31 | str = str.trim(); 32 | int len = str.length(); 33 | if (len == 0 || len % 2 == 1) 34 | return null; 35 | 36 | byte[] b = new byte[len / 2]; 37 | try { 38 | for (int i = 0; i < str.length(); i += 2) { 39 | b[i / 2] = (byte) Integer.decode("0x" + str.substring(i, i + 2)).intValue(); 40 | } 41 | return b; 42 | } catch (Exception e) { 43 | return null; 44 | } 45 | } 46 | 47 | public static void initImgFont() { 48 | URL fontUrl = CaptchaImgFont.class.getClassLoader().getResource("font.txt"); 49 | try { 50 | fontStr = FileUtil.readFile(fontUrl); 51 | } catch (Exception e) { 52 | fontStr = ""; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/test/TestAsyncTimeout.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.test; 2 | 3 | import com.app.mvc.http.HttpClients; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import java.util.concurrent.Callable; 7 | import java.util.concurrent.ExecutionException; 8 | import java.util.concurrent.ExecutorService; 9 | import java.util.concurrent.Executors; 10 | import java.util.concurrent.Future; 11 | import java.util.concurrent.TimeUnit; 12 | import java.util.concurrent.TimeoutException; 13 | 14 | /** 15 | * Created by jimin on 16/3/23. 16 | */ 17 | @Slf4j 18 | public class TestAsyncTimeout { 19 | public static void main(String[] args) { 20 | ExecutorService poll = Executors.newFixedThreadPool(100); 21 | Future future = poll.submit(new Callable() { 22 | @Override 23 | public Boolean call() throws Exception { 24 | Thread.sleep(1000 * 10); 25 | System.out.println("任务执行完成"); 26 | return true; 27 | } 28 | }); 29 | try { 30 | future.get(3, TimeUnit.SECONDS); 31 | } catch (InterruptedException e) { 32 | log.error("InterruptedException", e); //get为一个等待过程,异常中止get会抛出异常 33 | } catch (ExecutionException e) { 34 | log.error("ExecutionException", e); //submit计算出现异常 35 | } catch (TimeoutException e) { 36 | log.error("TimeoutException", e); //超时异常 37 | future.cancel(true); //超时后取消任务 38 | } finally { 39 | poll.shutdown(); 40 | } 41 | try { 42 | HttpClients.asyncClient(1, 1).asyncGet("https://www.baidu.com"); 43 | } catch (Exception e) { 44 | log.error("xxx", e); 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/http/HttpClients.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.http; 2 | 3 | /** 4 | * http客户端工厂方法,支持同步异步以及https客户端创建 5 | * Created by jimin on 16/03/10. 6 | */ 7 | public class HttpClients { 8 | 9 | /** 10 | * 一些常用的 timeout 值,尽量使用这些常量,如果这些常量不满足,再考虑使用自定义的 timeout 值 11 | */ 12 | public static final int TIMEOUT_SHORT = 5; 13 | public static final int TIMEOUT_MEDIUM = 30; 14 | public static final int TIMEOUT_LONG = 120; 15 | public static final int TIMEOUT_VERY_LONG = 300; 16 | 17 | /** 18 | * 获取同步http客户端 19 | * 20 | * @return AbstractHttpClient 21 | */ 22 | public static AbstractHttpClient syncClient() { 23 | return new SyncHttpClient(); 24 | } 25 | 26 | /** 27 | * 获取同步http客户端 28 | * 29 | * @param connTimeout int 30 | * @param soTimeout int 31 | * @return AbstractHttpClient 32 | */ 33 | public static AbstractHttpClient syncClient(int connTimeout, int soTimeout) { 34 | return new SyncHttpClient().connectionTimeout(connTimeout).soTimeout(soTimeout); 35 | } 36 | 37 | /** 38 | * 获取异步http客户端 39 | * 40 | * @param connTimeout int 41 | * @param soTimeout int 42 | * @return AbstractHttpClient 43 | */ 44 | public static AbstractHttpClient asyncClient(int connTimeout, int soTimeout) { 45 | return new AsyncHttpClient().connectionTimeout(connTimeout).soTimeout(soTimeout); 46 | } 47 | 48 | /** 49 | * 获取异步http客户端 50 | * 51 | * @return AbstractHttpClient 52 | */ 53 | public static AbstractHttpClient asyncClient() { 54 | return new AsyncHttpClient(); 55 | } 56 | 57 | /** 58 | * 关闭客户端资源,关闭后将不可再使用异步客户端 59 | */ 60 | public static void shutdownHttpClient() { 61 | AsyncHttpClient.threadPool.shutdown(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/PropertiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.util.Properties; 7 | 8 | /** 9 | * Created by jimin on 16/2/4. 10 | */ 11 | @Slf4j 12 | public final class PropertiesUtil { 13 | /**** 14 | * 配置文件. 15 | */ 16 | private static final String DEFAULT_PROP_FILE = "properties/default.properties"; 17 | private static final String CONFIG_PROP_FILE = "properties/config.properties"; 18 | 19 | private static Properties prop = new Properties(); 20 | 21 | /**** 22 | * 定义常量. 23 | */ 24 | private PropertiesUtil() { 25 | } 26 | 27 | static { 28 | reload(); 29 | } 30 | 31 | public static void reload() { 32 | try { 33 | Properties properties = new Properties(); 34 | properties.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(DEFAULT_PROP_FILE)); 35 | properties.load(PropertiesUtil.class.getClassLoader().getResourceAsStream(CONFIG_PROP_FILE)); 36 | prop = properties; 37 | } catch (Throwable e) { 38 | log.error("load properties exception", e); 39 | } 40 | } 41 | 42 | public static String get(String key) { 43 | if (StringUtils.isBlank(key)) { 44 | return ""; 45 | } 46 | return String.valueOf(prop.get(key)); 47 | } 48 | 49 | public static String get(String key, String defaultValue) { 50 | if (StringUtils.isBlank(key)) { 51 | return defaultValue; 52 | } 53 | return String.valueOf(prop.get(key)); 54 | } 55 | 56 | public static void main(String[] args) { 57 | System.out.println(get("test")); 58 | System.out.println(get("isProd")); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/util/MailUtil.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.util; 2 | 3 | import com.app.mvc.beans.Mail; 4 | import com.app.mvc.config.GlobalConfig; 5 | import com.app.mvc.config.GlobalConfigKey; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.apache.commons.mail.EmailException; 9 | import org.apache.commons.mail.HtmlEmail; 10 | 11 | /** 12 | * Created by jimin on 15/11/21. 13 | */ 14 | 15 | @Slf4j 16 | public class MailUtil { 17 | 18 | public static boolean send(Mail mail) { 19 | 20 | String from = GlobalConfig.getStringValue(GlobalConfigKey.MAIL_SEND_FROM, ""); 21 | int port = GlobalConfig.getIntValue(GlobalConfigKey.MAIL_SEND_PORT, 25); 22 | String host = GlobalConfig.getStringValue(GlobalConfigKey.MAIL_SEND_SMTP, ""); 23 | String pass = GlobalConfig.getStringValue(GlobalConfigKey.MAIL_SEND_PASSWORD, ""); 24 | String nickname = GlobalConfig.getStringValue(GlobalConfigKey.MAIL_SEND_NICKNAME, ""); 25 | 26 | HtmlEmail email = new HtmlEmail(); 27 | try { 28 | email.setHostName(host); 29 | email.setCharset("UTF-8"); 30 | for (String str : mail.getReceivers()) { 31 | email.addTo(str); 32 | } 33 | email.setFrom(from, nickname); 34 | email.setSmtpPort(port); 35 | email.setAuthentication(from, pass); 36 | email.setSubject(mail.getSubject()); 37 | email.setMsg(mail.getMessage()); 38 | email.send(); 39 | log.info("{} 发送邮件到 {}", from, StringUtils.join(mail.getReceivers(), ",")); 40 | return true; 41 | } catch (EmailException e) { 42 | log.error(from + "发送邮件到" + StringUtils.join(mail.getReceivers(), ",") + "失败", e); 43 | return false; 44 | } 45 | } 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/spring-rabbit.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/ThreadPool.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import com.app.mvc.config.GlobalConfig; 4 | import com.app.mvc.config.GlobalConfigKey; 5 | 6 | import java.util.concurrent.ArrayBlockingQueue; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.Future; 9 | import java.util.concurrent.RejectedExecutionException; 10 | import java.util.concurrent.ThreadPoolExecutor; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | /** 14 | * Created by jimin on 15/12/1. 15 | */ 16 | public class ThreadPool { 17 | 18 | private static ExecutorService defaultExecutor; // 线程池 19 | 20 | /****** 初始化线程池 ******/ 21 | static { 22 | defaultExecutor = new ThreadPoolExecutor(GlobalConfig.getIntValue(GlobalConfigKey.DEFAULT_EXECUTOR_CORESIZE, 40), // 核心池大小 23 | GlobalConfig.getIntValue(GlobalConfigKey.DEFAULT_EXECUTOR_MAXSIZE, 100), // 最大线程数 24 | GlobalConfig.getIntValue(GlobalConfigKey.DEFAULT_EXECUTOR_KEEPALIVE_SECONDS, 120), // 空闲等待时间 25 | TimeUnit.SECONDS, // 时间单位 26 | new ArrayBlockingQueue(GlobalConfig.getIntValue(GlobalConfigKey.DEFAULT_EXECUTOR_QUEUESIZE, 1000)), // 循环数组 + 指定大小 27 | new ThreadPoolExecutor.DiscardOldestPolicy() // 抛弃最早的请求 28 | ); 29 | } 30 | 31 | /** 32 | * 在未来某个时间执行给定的命令 33 | */ 34 | public static void execute(Runnable runnable) throws RejectedExecutionException { 35 | defaultExecutor.execute(runnable); 36 | } 37 | 38 | /** 39 | * 提交一个 Runnable 任务用于执行,并返回一个表示该任务的 Future 40 | */ 41 | public static Future submit(Runnable runnable) throws RejectedExecutionException { 42 | return defaultExecutor.submit(runnable); 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/ConfigurationService.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.config; 2 | 3 | import com.app.mvc.acl.convert.BaseConvert; 4 | import com.app.mvc.acl.util.RequestHolder; 5 | import com.app.mvc.beans.PageQuery; 6 | import com.app.mvc.beans.PageResult; 7 | import org.springframework.stereotype.Service; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by jimin on 15/11/7. 14 | */ 15 | @Service 16 | public class ConfigurationService { 17 | 18 | @Resource 19 | private ConfigurationDao configurationDao; 20 | 21 | public List getAll() { 22 | return configurationDao.getAll(); 23 | } 24 | 25 | public PageResult getByPage(PageQuery page) { 26 | BaseConvert.checkPara(page); 27 | int count = configurationDao.count(); 28 | if (count > 0) { 29 | List list = configurationDao.getByPage(page); 30 | return PageResult.builder().total(count).data(list).build(); 31 | } 32 | return PageResult.builder().build(); 33 | } 34 | 35 | public Configuration saveOrUpdate(ConfigurationParam param) { 36 | Configuration configuration = configurationDao.findByK(param.getK()); 37 | if (configuration == null) { 38 | configuration = generate(param); 39 | configurationDao.insert(configuration); 40 | } else { 41 | configuration.setV(param.getV()); 42 | configuration.setOperator(RequestHolder.getCurrentUser().getUsername()); 43 | configuration.setComment(param.getComment()); 44 | configurationDao.updateByK(configuration); 45 | } 46 | return configuration; 47 | } 48 | 49 | private Configuration generate(ConfigurationParam param) { 50 | return new Configuration(param.getK(), param.getV(), RequestHolder.getCurrentUser().getUsername(), param.getComment()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | name, 11 | type, 12 | status, 13 | supplier_id as supplierId, 14 | remark, 15 | operator, 16 | operate_time as operateTime, 17 | operate_ip as operateIp 18 | 19 | 20 | 21 | INSERT INTO sys_role (name, type, status, supplier_id, remark, operator, operate_ip) 22 | VALUES (#{name}, #{type}, #{status}, #{supplierId}, #{remark}, #{operator}, #{operateIp}) 23 | 24 | 25 | SELECT LAST_INSERT_ID() AS id 26 | 27 | 28 | 29 | 30 | UPDATE sys_role 31 | SET name = #{name}, 32 | type = #{type}, 33 | status = #{status}, 34 | remark = #{remark}, 35 | operator = #{operator}, 36 | operate_time = now(), 37 | operate_ip = #{operateIp} 38 | WHERE id = #{id} 39 | 40 | 41 | 47 | 48 | 54 | 55 | 56 | DELETE FROM sys_role 57 | WHERE id = #{id} 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/schedule/AutoRegisterScheduleJob.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.schedule; 2 | 3 | import com.app.mvc.common.SpringHelper; 4 | import com.app.mvc.util.ClassUtil; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.commons.collections.CollectionUtils; 7 | 8 | import java.lang.reflect.Method; 9 | import java.util.List; 10 | 11 | /** 12 | * Created by jimin on 16/5/9. 13 | */ 14 | @Slf4j 15 | public class AutoRegisterScheduleJob { 16 | 17 | public static void registerWhenStartUp() { 18 | log.info("auto register schedule job start"); 19 | ScheduleJobSettingDao scheduleJobSettingDao = SpringHelper.popBean(ScheduleJobSettingDao.class); 20 | List clazzList = ClassUtil.getSubClassList(AbstractScheduleJob.class, "com.app.mvc"); 21 | if (CollectionUtils.isEmpty(clazzList)) { 22 | return; 23 | } 24 | for (Class clazz : clazzList) { 25 | String className = clazz.getName(); 26 | if (scheduleJobSettingDao.countByClassPath(className) == 0) { 27 | try { 28 | Object instance = clazz.newInstance(); // 此处需要使用实例化后的对象去invoke才能拿到方法的返回值 29 | Method scheduleIdMethod = clazz.getDeclaredMethod("scheduleId"); 30 | Method groupIdMethod = clazz.getDeclaredMethod("groupId"); 31 | log.info("find a new schedule job to register, {}", className); 32 | ScheduledJobSetting setting = ScheduledJobSetting.builder().groupId((String) groupIdMethod.invoke(instance)) 33 | .scheduleId((String) scheduleIdMethod.invoke(instance)).classPath(className).build(); 34 | scheduleJobSettingDao.save(setting); 35 | } catch (Throwable t) { 36 | log.error("auto register schedule job exception, name: " + className, t); 37 | } 38 | } 39 | } 40 | log.info("auto register schedule job end"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/config/ConfigurationController.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.config; 2 | 3 | import com.app.mvc.acl.util.RequestHolder; 4 | import com.app.mvc.beans.JsonData; 5 | import com.app.mvc.beans.PageQuery; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | import org.springframework.web.servlet.ModelAndView; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * Created by jimin on 15/11/7. 16 | */ 17 | @Slf4j 18 | @Controller 19 | @RequestMapping("/config") 20 | public class ConfigurationController { 21 | 22 | @Resource 23 | private ConfigurationService configurationService; 24 | 25 | @ResponseBody 26 | @RequestMapping("/page.do") 27 | public ModelAndView page() { 28 | return new ModelAndView("config"); 29 | } 30 | 31 | @ResponseBody 32 | @RequestMapping("/reloadAll.json") 33 | public JsonData reloadAll() { 34 | log.info("reload all machine config, username:{}", RequestHolder.getCurrentUser().getUsername()); 35 | return JsonData.success(GlobalConfig.loadMachineConfig()); 36 | } 37 | 38 | @ResponseBody 39 | @RequestMapping("/reload.json") 40 | public JsonData reload() { 41 | log.info("reload config, username:{}", RequestHolder.getCurrentUser().getUsername()); 42 | GlobalConfig.loadAllConfig(); 43 | return JsonData.success(); 44 | } 45 | 46 | @ResponseBody 47 | @RequestMapping("/save.json") 48 | public JsonData save(ConfigurationParam param) { 49 | Configuration configuration = configurationService.saveOrUpdate(param); 50 | return JsonData.success(configuration); 51 | } 52 | 53 | @ResponseBody 54 | @RequestMapping("/page.json") 55 | public JsonData page(PageQuery page) { 56 | return JsonData.success(configurationService.getByPage(page)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ConfigurationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | k, 10 | v, 11 | operator, 12 | comment 13 | 14 | 15 | 21 | 22 | 23 | INSERT INTO configuration 24 | (k, v, operator, comment) 25 | VALUES 26 | (#{k}, #{v}, #{operator}, #{comment}) 27 | 28 | 29 | 33 | 34 | 39 | 40 | 47 | 48 | 49 | UPDATE configuration 50 | SET v = #{v} 51 | 52 | , operator = #{operator} 53 | 54 | 55 | , comment = #{comment} 56 | 57 | WHERE k = #{k} 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/com/app/mvc/common/LogEmailFilter.java: -------------------------------------------------------------------------------- 1 | package com.app.mvc.common; 2 | 3 | import ch.qos.logback.classic.Level; 4 | import ch.qos.logback.classic.spi.ILoggingEvent; 5 | import ch.qos.logback.core.filter.Filter; 6 | import ch.qos.logback.core.spi.FilterReply; 7 | import com.app.mvc.config.GlobalConfig; 8 | import com.app.mvc.config.GlobalConfigKey; 9 | import com.google.common.base.Splitter; 10 | import org.apache.commons.lang3.StringUtils; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * 基于logback的报警邮件过滤器,该过滤器主要提供如下功能: 16 | * (1)等级过滤,目前只接受error的日志 17 | * (2)内容过滤,可以通过正则表达式匹配对应的内容从而打倒过滤效果 18 | * (3)日志内容过滤的动态配置功能,该功能主要依赖配置库。 19 | * 配置表中保存的内容是: 20 | * logback.filter.msg="filter1";"filter2";..."filterN" 21 | */ 22 | public class LogEmailFilter extends Filter { 23 | 24 | @Override 25 | public FilterReply decide(ILoggingEvent event) { 26 | 27 | if (!event.getLevel().equals(Level.ERROR)) { 28 | return FilterReply.DENY; 29 | } 30 | 31 | // 是否开通邮件通知 32 | boolean isOpenEmail = GlobalConfig.getBooleanValue(GlobalConfigKey.LOGBACK_EMAIL_OPEN, false); 33 | if (!isOpenEmail) { 34 | return FilterReply.DENY; 35 | } 36 | 37 | // 是否过滤指定的logger 38 | String filterString = GlobalConfig.getStringValue(GlobalConfigKey.LOGBACK_FILTER_MSG, ""); 39 | if (StringUtils.isBlank(filterString)) { 40 | return FilterReply.ACCEPT; 41 | } 42 | 43 | String message = event.getMessage(); 44 | List list = Splitter.on(";").splitToList(filterString); 45 | for (String filterMsg : list) { 46 | if (filterMsg.length() > 2) { 47 | // 每项均为“”包裹 48 | filterMsg = filterMsg.substring(1, filterMsg.length() - 1); 49 | if (message.contains(filterMsg)) { 50 | return FilterReply.DENY; 51 | } 52 | } 53 | } 54 | 55 | return FilterReply.ACCEPT; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/webapp/assets/js/flot/jquery.flot.resize.min.js: -------------------------------------------------------------------------------- 1 | (function($,t,n){function p(){for(var n=r.length-1;n>=0;n--){var o=$(r[n]);if(o[0]==t||o.is(":visible")){var h=o.width(),d=o.height(),v=o.data(a);!v||h===v.w&&d===v.h?i[f]=i[l]:(i[f]=i[c],o.trigger(u,[v.w=h,v.h=d]))}else v=o.data(a),v.w=0,v.h=0}s!==null&&(s=t.requestAnimationFrame(p))}var r=[],i=$.resize=$.extend($.resize,{}),s,o="setTimeout",u="resize",a=u+"-special-event",f="delay",l="pendingDelay",c="activeDelay",h="throttleWindow";i[l]=250,i[c]=20,i[f]=i[l],i[h]=!0,$.event.special[u]={setup:function(){if(!i[h]&&this[o])return!1;var t=$(this);r.push(this),t.data(a,{w:t.width(),h:t.height()}),r.length===1&&(s=n,p())},teardown:function(){if(!i[h]&&this[o])return!1;var t=$(this);for(var n=r.length-1;n>=0;n--)if(r[n]==this){r.splice(n,1);break}t.removeData(a),r.length||(cancelAnimationFrame(s),s=null)},add:function(t){function s(t,i,s){var o=$(this),u=o.data(a);u.w=i!==n?i:o.width(),u.h=s!==n?s:o.height(),r.apply(this,arguments)}if(!i[h]&&this[o])return!1;var r;if($.isFunction(t))return r=t,s;r=t.handler,t.handler=s}},t.requestAnimationFrame||(t.requestAnimationFrame=function(){return t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e,n){return t.setTimeout(e,i[f])}}()),t.cancelAnimationFrame||(t.cancelAnimationFrame=function(){return t.webkitCancelRequestAnimationFrame||t.mozCancelRequestAnimationFrame||t.oCancelRequestAnimationFrame||t.msCancelRequestAnimationFrame||clearTimeout}())})(jQuery,this);(function($){var options={};function init(plot){function onResize(){var placeholder=plot.getPlaceholder();if(placeholder.width()==0||placeholder.height()==0)return;plot.resize();plot.setupGrid();plot.draw()}function bindEvents(plot,eventHolder){plot.getPlaceholder().resize(onResize)}function shutdown(plot,eventHolder){plot.getPlaceholder().unbind("resize",onResize)}plot.hooks.bindEvents.push(bindEvents);plot.hooks.shutdown.push(shutdown)}$.plot.plugins.push({init:init,options:options,name:"resize",version:"1.0"})})(jQuery); -------------------------------------------------------------------------------- /src/main/resources/mapper/ArticleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | content, 11 | read_times as readTimes, 12 | title, 13 | publish_time as publishTime, 14 | operator, 15 | operate_ip as operateIp, 16 | operate_time as operateTime 17 | 18 | 19 | 20 | INSERT INTO article 21 | (content, title, read_times, publish_time, operator, operate_ip, operate_time) 22 | VALUES 23 | (#{content}, #{title}, 0, now(), #{operator}, #{operateIp}, now()) 24 | 25 | 26 | 27 | UPDATE article 28 | SET content = #{content}, 29 | title = #{title}, 30 | operator = #{operator}, 31 | operate_ip = #{operateIp}, 32 | operate_time = now() 33 | WHERE id = #{id} 34 | 35 | 36 | 41 | 42 | 48 | 49 | 53 | 54 | 55 | UPDATE article 56 | SET read_times = read_times + 1 57 | WHERE id = #{id} 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ScheduleExecuteResultMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | id, 10 | schedule_id as scheduleId, 11 | status, 12 | start_time as startTime, 13 | end_time as endTime 14 | 15 | 16 | 17 | INSERT INTO schedule_execute_result 18 | (schedule_id, status, start_time, end_time) 19 | VALUES 20 | (#{scheduleId}, #{status}, now(), null) 21 | 22 | 23 | 24 | UPDATE schedule_execute_result 25 | SET status = #{status}, 26 | end_time = now() 27 | WHERE id = #{id} 28 | 29 | 30 | 31 | 39 | 40 | 45 | 46 | 54 | --------------------------------------------------------------------------------