Repository: yjjdick/sdb-mall
Branch: master
Commit: 1dd9223b77a3
Files: 451
Total size: 5.6 MB
Directory structure:
gitextract_r7yl04yy/
├── .gitattributes
├── .gitignore
├── .gitlab-ci.yml
├── LICENSE
├── README.md
├── db/
│ ├── init.sql
│ └── sdb_带测试数据.sql
├── pom-war.xml
├── pom.xml
├── sdb.iml
└── src/
├── main/
│ ├── java/
│ │ ├── com/
│ │ │ └── baidu/
│ │ │ └── ueditor/
│ │ │ ├── ActionEnter.java
│ │ │ ├── ConfigManager.java
│ │ │ ├── Encoder.java
│ │ │ ├── PathFormat.java
│ │ │ ├── define/
│ │ │ │ ├── ActionMap.java
│ │ │ │ ├── ActionState.java
│ │ │ │ ├── AppInfo.java
│ │ │ │ ├── BaseState.java
│ │ │ │ ├── FileType.java
│ │ │ │ ├── MIMEType.java
│ │ │ │ ├── MultiState.java
│ │ │ │ └── State.java
│ │ │ ├── hunter/
│ │ │ │ ├── FileManager.java
│ │ │ │ └── ImageHunter.java
│ │ │ └── upload/
│ │ │ ├── Base64Uploader.java
│ │ │ ├── BinaryUploader.java
│ │ │ ├── StorageManager.java
│ │ │ └── Uploader.java
│ │ └── io/
│ │ └── sdb/
│ │ ├── SdbApplication.java
│ │ ├── builder/
│ │ │ ├── AbstractBuilder.java
│ │ │ ├── ImageBuilder.java
│ │ │ ├── MyMetaBuilder.java
│ │ │ └── TextBuilder.java
│ │ ├── common/
│ │ │ ├── annotation/
│ │ │ │ ├── JFinalTx.java
│ │ │ │ ├── Login.java
│ │ │ │ ├── LoginUser.java
│ │ │ │ └── SysLog.java
│ │ │ ├── aspect/
│ │ │ │ ├── RedisAspect.java
│ │ │ │ └── SysLogAspect.java
│ │ │ ├── entity/
│ │ │ │ ├── AreaNode.java
│ │ │ │ ├── Filter.java
│ │ │ │ ├── Node.java
│ │ │ │ ├── Order.java
│ │ │ │ └── kuaidi100/
│ │ │ │ ├── MapCustomConverter.java
│ │ │ │ ├── NoticeRequest.java
│ │ │ │ ├── NoticeResponse.java
│ │ │ │ ├── Result.java
│ │ │ │ ├── ResultItem.java
│ │ │ │ ├── TaskRequest.java
│ │ │ │ └── TaskResponse.java
│ │ │ ├── exception/
│ │ │ │ ├── RRException.java
│ │ │ │ └── RRExceptionHandler.java
│ │ │ ├── utils/
│ │ │ │ ├── ConfigConstant.java
│ │ │ │ ├── Constant.java
│ │ │ │ ├── DateUtils.java
│ │ │ │ ├── EnumUtil.java
│ │ │ │ ├── GenericsUtils.java
│ │ │ │ ├── HttpContextUtils.java
│ │ │ │ ├── HttpRequest.java
│ │ │ │ ├── IPUtils.java
│ │ │ │ ├── JfEnjoy.java
│ │ │ │ ├── JsonUtils.java
│ │ │ │ ├── JwtUtils.java
│ │ │ │ ├── MapUtils.java
│ │ │ │ ├── MoneyUtils.java
│ │ │ │ ├── PageUtils.java
│ │ │ │ ├── Query.java
│ │ │ │ ├── R.java
│ │ │ │ ├── RecordUtils.java
│ │ │ │ ├── RedisKeys.java
│ │ │ │ ├── RedisLock.java
│ │ │ │ ├── RedisUtils.java
│ │ │ │ ├── ShiroUtils.java
│ │ │ │ ├── SpringContextUtils.java
│ │ │ │ ├── SqlHelper.java
│ │ │ │ ├── TreeBuilder.java
│ │ │ │ ├── _JFCodeGenerator.java
│ │ │ │ ├── _JFinalGenerator.java
│ │ │ │ └── tpl/
│ │ │ │ ├── html/
│ │ │ │ │ ├── add-or-update.html
│ │ │ │ │ └── index.html
│ │ │ │ └── java/
│ │ │ │ ├── controller.html
│ │ │ │ ├── dao.html
│ │ │ │ ├── service.html
│ │ │ │ └── serviceImpl.html
│ │ │ ├── validator/
│ │ │ │ ├── Assert.java
│ │ │ │ ├── ValidatorUtils.java
│ │ │ │ └── group/
│ │ │ │ ├── AddGroup.java
│ │ │ │ ├── AliyunGroup.java
│ │ │ │ ├── Group.java
│ │ │ │ ├── QcloudGroup.java
│ │ │ │ ├── QiniuGroup.java
│ │ │ │ └── UpdateGroup.java
│ │ │ └── xss/
│ │ │ ├── HTMLFilter.java
│ │ │ ├── SQLFilter.java
│ │ │ ├── XssFilter.java
│ │ │ └── XssHttpServletRequestWrapper.java
│ │ ├── config/
│ │ │ ├── ActiveRecordConfig.java
│ │ │ ├── AlipayConfig.java
│ │ │ ├── CorsConfig.java
│ │ │ ├── FilterConfig.java
│ │ │ ├── JFinalTxAop.java
│ │ │ ├── KaptchaConfig.java
│ │ │ ├── Kuaidi100Config.java
│ │ │ ├── OrderProperties.java
│ │ │ ├── RedisConfig.java
│ │ │ ├── ShiroConfig.java
│ │ │ ├── SpringBootConfig.java
│ │ │ ├── SwaggerConfig.java
│ │ │ ├── WebMvcConfig.java
│ │ │ ├── WechatOpenConfig.java
│ │ │ ├── WechatPayConfig.java
│ │ │ ├── WxMaConfiguration.java
│ │ │ ├── WxMaProperties.java
│ │ │ ├── WxMpConfiguration.java
│ │ │ └── WxMpProperties.java
│ │ ├── controller/
│ │ │ ├── AbstractController.java
│ │ │ ├── AppLoginController.java
│ │ │ ├── AppRegisterController.java
│ │ │ ├── AppTestController.java
│ │ │ ├── CartController.java
│ │ │ ├── FavoriteGoodsController.java
│ │ │ ├── FileController.java
│ │ │ ├── GoodsController.java
│ │ │ ├── GrouponController.java
│ │ │ ├── OrderController.java
│ │ │ ├── PayController.java
│ │ │ ├── ProductCategoryController.java
│ │ │ ├── ProductController.java
│ │ │ ├── ScheduleJobController.java
│ │ │ ├── ScheduleJobLogController.java
│ │ │ ├── SpecificationController.java
│ │ │ ├── SysCampaignController.java
│ │ │ ├── SysConfigController.java
│ │ │ ├── SysDeliveryCorpController.java
│ │ │ ├── SysFavoriteGoodsController.java
│ │ │ ├── SysGoodsController.java
│ │ │ ├── SysGrouponController.java
│ │ │ ├── SysGrouponTeamController.java
│ │ │ ├── SysLogController.java
│ │ │ ├── SysLoginController.java
│ │ │ ├── SysLogisticsController.java
│ │ │ ├── SysMenuController.java
│ │ │ ├── SysOrderController.java
│ │ │ ├── SysOssController.java
│ │ │ ├── SysProductCategoryController.java
│ │ │ ├── SysRoleController.java
│ │ │ ├── SysSpecificationController.java
│ │ │ ├── SysUserController.java
│ │ │ ├── TestController.java
│ │ │ ├── UEditorController.java
│ │ │ ├── WxMaMediaController.java
│ │ │ ├── WxMaUserController.java
│ │ │ ├── WxPayController.java
│ │ │ └── WxPortalController.java
│ │ ├── dao/
│ │ │ ├── AreaDao.java
│ │ │ ├── BaseDao.java
│ │ │ ├── CampaignDao.java
│ │ │ ├── CartDao.java
│ │ │ ├── DeliveryCorpDao.java
│ │ │ ├── FavoriteGoodsDao.java
│ │ │ ├── GoodsDao.java
│ │ │ ├── GrouponDao.java
│ │ │ ├── GrouponTeamDao.java
│ │ │ ├── LogisticsDao.java
│ │ │ ├── OrderDetailDao.java
│ │ │ ├── OrderMasterDao.java
│ │ │ ├── ProductCategoryDao.java
│ │ │ ├── ProductDao.java
│ │ │ ├── ReceiverDao.java
│ │ │ ├── ScheduleJobDao.java
│ │ │ ├── ScheduleJobLogDao.java
│ │ │ ├── SnDao.java
│ │ │ ├── SpecificationDao.java
│ │ │ ├── SysCaptchaDao.java
│ │ │ ├── SysConfigDao.java
│ │ │ ├── SysLogDao.java
│ │ │ ├── SysMenuDao.java
│ │ │ ├── SysOssDao.java
│ │ │ ├── SysRoleDao.java
│ │ │ ├── SysRoleMenuDao.java
│ │ │ ├── SysUserDao.java
│ │ │ ├── SysUserRoleDao.java
│ │ │ ├── SysUserTokenDao.java
│ │ │ └── UserDao.java
│ │ ├── datasources/
│ │ │ ├── DataSourceNames.java
│ │ │ ├── DynamicDataSource.java
│ │ │ ├── DynamicDataSourceConfig.java
│ │ │ ├── annotation/
│ │ │ │ └── DataSource.java
│ │ │ └── aspect/
│ │ │ └── DataSourceAspect.java
│ │ ├── dto/
│ │ │ ├── CartDTO.java
│ │ │ ├── FavoriteGoodsDTO.java
│ │ │ ├── GoodsDTO.java
│ │ │ ├── OrderDTO.java
│ │ │ └── ProductDTO.java
│ │ ├── enums/
│ │ │ ├── CampaignEnum.java
│ │ │ ├── GeneralEnum.java
│ │ │ ├── GrouponStatusEnum.java
│ │ │ ├── IEnum.java
│ │ │ ├── Language.java
│ │ │ ├── OrderStatusEnum.java
│ │ │ ├── PayStatusEnum.java
│ │ │ ├── ProductStatusEnum.java
│ │ │ ├── ResultEnum.java
│ │ │ ├── SnEnum.java
│ │ │ └── VolunteerStateEnum.java
│ │ ├── form/
│ │ │ ├── CartForm.java
│ │ │ ├── CheckOutForm.java
│ │ │ ├── GoodsData.java
│ │ │ ├── GoodsForm.java
│ │ │ ├── GoodsListForm.java
│ │ │ ├── GoodsParaData.java
│ │ │ ├── GoodsParaEntryData.java
│ │ │ ├── GoodsSpecData.java
│ │ │ ├── GoodsSpecGroupData.java
│ │ │ ├── InvoiceInfo.java
│ │ │ ├── LoginForm.java
│ │ │ ├── MaLoginForm.java
│ │ │ ├── NewsAddForm.java
│ │ │ ├── OrderDetailForm.java
│ │ │ ├── OrderForm.java
│ │ │ ├── PasswordForm.java
│ │ │ ├── ProductInfo.java
│ │ │ ├── ReceiveInfo.java
│ │ │ ├── RefundForm.java
│ │ │ ├── RegisterForm.java
│ │ │ ├── SysLoginForm.java
│ │ │ ├── SysNewsForm.java
│ │ │ └── SysOrderForm.java
│ │ ├── handler/
│ │ │ ├── AbstractHandler.java
│ │ │ ├── KfSessionHandler.java
│ │ │ ├── LocationHandler.java
│ │ │ ├── LogHandler.java
│ │ │ ├── MenuHandler.java
│ │ │ ├── MsgHandler.java
│ │ │ ├── NullHandler.java
│ │ │ ├── ScanHandler.java
│ │ │ ├── StoreCheckNotifyHandler.java
│ │ │ ├── SubscribeHandler.java
│ │ │ └── UnsubscribeHandler.java
│ │ ├── interceptor/
│ │ │ └── AuthorizationInterceptor.java
│ │ ├── job/
│ │ │ ├── config/
│ │ │ │ └── ScheduleConfig.java
│ │ │ ├── task/
│ │ │ │ └── TestTask.java
│ │ │ └── utils/
│ │ │ ├── ScheduleJob.java
│ │ │ ├── ScheduleRunnable.java
│ │ │ └── ScheduleUtils.java
│ │ ├── model/
│ │ │ ├── Area.java
│ │ │ ├── Campaign.java
│ │ │ ├── Cart.java
│ │ │ ├── DeliveryCorp.java
│ │ │ ├── FavoriteGoods.java
│ │ │ ├── Goods.java
│ │ │ ├── Groupon.java
│ │ │ ├── GrouponTeam.java
│ │ │ ├── Logistics.java
│ │ │ ├── OrderDetail.java
│ │ │ ├── OrderMaster.java
│ │ │ ├── Product.java
│ │ │ ├── ProductCategory.java
│ │ │ ├── Receiver.java
│ │ │ ├── ScheduleJob.java
│ │ │ ├── ScheduleJobLog.java
│ │ │ ├── Sn.java
│ │ │ ├── Specification.java
│ │ │ ├── SysCaptcha.java
│ │ │ ├── SysConfig.java
│ │ │ ├── SysLog.java
│ │ │ ├── SysMenu.java
│ │ │ ├── SysOss.java
│ │ │ ├── SysRole.java
│ │ │ ├── SysRoleMenu.java
│ │ │ ├── SysUser.java
│ │ │ ├── SysUserRole.java
│ │ │ ├── SysUserToken.java
│ │ │ ├── TbUser.java
│ │ │ ├── User.java
│ │ │ ├── _MappingKit.java
│ │ │ └── base/
│ │ │ ├── BaseArea.java
│ │ │ ├── BaseCampaign.java
│ │ │ ├── BaseCart.java
│ │ │ ├── BaseDeliveryCorp.java
│ │ │ ├── BaseFavoriteGoods.java
│ │ │ ├── BaseGoods.java
│ │ │ ├── BaseGroupon.java
│ │ │ ├── BaseGrouponTeam.java
│ │ │ ├── BaseLogistics.java
│ │ │ ├── BaseOrderDetail.java
│ │ │ ├── BaseOrderMaster.java
│ │ │ ├── BaseProduct.java
│ │ │ ├── BaseProductCategory.java
│ │ │ ├── BaseReceiver.java
│ │ │ ├── BaseScheduleJob.java
│ │ │ ├── BaseScheduleJobLog.java
│ │ │ ├── BaseSn.java
│ │ │ ├── BaseSpecification.java
│ │ │ ├── BaseSysCaptcha.java
│ │ │ ├── BaseSysConfig.java
│ │ │ ├── BaseSysLog.java
│ │ │ ├── BaseSysMenu.java
│ │ │ ├── BaseSysOss.java
│ │ │ ├── BaseSysRole.java
│ │ │ ├── BaseSysRoleMenu.java
│ │ │ ├── BaseSysUser.java
│ │ │ ├── BaseSysUserRole.java
│ │ │ ├── BaseSysUserToken.java
│ │ │ ├── BaseTbUser.java
│ │ │ ├── BaseTestTable.java
│ │ │ ├── BaseUser.java
│ │ │ └── BaseVolunteerInfo.java
│ │ ├── oss/
│ │ │ └── cloud/
│ │ │ ├── AliyunCloudStorageService.java
│ │ │ ├── CloudStorageConfig.java
│ │ │ ├── CloudStorageService.java
│ │ │ ├── OSSFactory.java
│ │ │ ├── QcloudCloudStorageService.java
│ │ │ └── QiniuCloudStorageService.java
│ │ ├── resolver/
│ │ │ └── LoginUserHandlerMethodArgumentResolver.java
│ │ ├── serializer/
│ │ │ ├── Date2LongSerializer.java
│ │ │ └── Int2BoolSerializer.java
│ │ ├── service/
│ │ │ ├── AreaService.java
│ │ │ ├── BaseService.java
│ │ │ ├── CampaignService.java
│ │ │ ├── CartService.java
│ │ │ ├── DeliveryCorpService.java
│ │ │ ├── FavoriteGoodsService.java
│ │ │ ├── GoodsService.java
│ │ │ ├── GrouponService.java
│ │ │ ├── GrouponTeamService.java
│ │ │ ├── LogisticsService.java
│ │ │ ├── OrderDetailService.java
│ │ │ ├── OrderMasterService.java
│ │ │ ├── PayService.java
│ │ │ ├── ProductCategoryService.java
│ │ │ ├── ProductService.java
│ │ │ ├── ReceiverService.java
│ │ │ ├── ScheduleJobLogService.java
│ │ │ ├── ScheduleJobService.java
│ │ │ ├── ShiroService.java
│ │ │ ├── SnService.java
│ │ │ ├── SpecificationService.java
│ │ │ ├── SysCaptchaService.java
│ │ │ ├── SysConfigService.java
│ │ │ ├── SysLogService.java
│ │ │ ├── SysMenuService.java
│ │ │ ├── SysOssService.java
│ │ │ ├── SysRoleMenuService.java
│ │ │ ├── SysRoleService.java
│ │ │ ├── SysUserRoleService.java
│ │ │ ├── SysUserService.java
│ │ │ ├── SysUserTokenService.java
│ │ │ ├── UserService.java
│ │ │ └── impl/
│ │ │ ├── AreaServiceImpl.java
│ │ │ ├── BaseServiceImpl.java
│ │ │ ├── CampaignServiceImpl.java
│ │ │ ├── CartServiceImpl.java
│ │ │ ├── DeliveryCorpServiceImpl.java
│ │ │ ├── FavoriteGoodsServiceImpl.java
│ │ │ ├── GoodsServiceImpl.java
│ │ │ ├── GrouponServiceImpl.java
│ │ │ ├── GrouponTeamServiceImpl.java
│ │ │ ├── LogisticsServiceImpl.java
│ │ │ ├── MailService.java
│ │ │ ├── OrderDetailServiceImpl.java
│ │ │ ├── OrderMasterServiceImpl.java
│ │ │ ├── PayServiceImpl.java
│ │ │ ├── ProductCategoryServiceImpl.java
│ │ │ ├── ProductServiceImpl.java
│ │ │ ├── ReceiverServiceImpl.java
│ │ │ ├── ScheduleJobLogServiceImpl.java
│ │ │ ├── ScheduleJobServiceImpl.java
│ │ │ ├── ShiroServiceImpl.java
│ │ │ ├── SnServiceImpl.java
│ │ │ ├── SpecificationServiceImpl.java
│ │ │ ├── SysCaptchaServiceImpl.java
│ │ │ ├── SysConfigServiceImpl.java
│ │ │ ├── SysLogServiceImpl.java
│ │ │ ├── SysMenuServiceImpl.java
│ │ │ ├── SysOssServiceImpl.java
│ │ │ ├── SysRoleMenuServiceImpl.java
│ │ │ ├── SysRoleServiceImpl.java
│ │ │ ├── SysUserRoleServiceImpl.java
│ │ │ ├── SysUserServiceImpl.java
│ │ │ ├── SysUserTokenServiceImpl.java
│ │ │ └── UserServiceImpl.java
│ │ ├── sys/
│ │ │ ├── oauth2/
│ │ │ │ ├── OAuth2Filter.java
│ │ │ │ ├── OAuth2Realm.java
│ │ │ │ ├── OAuth2Token.java
│ │ │ │ └── TokenGenerator.java
│ │ │ └── redis/
│ │ │ └── SysConfigRedis.java
│ │ └── vo/
│ │ ├── DeliveryCorpVO.java
│ │ ├── GoodsVO.java
│ │ ├── GrouponDetailVO.java
│ │ ├── GrouponTeamVO.java
│ │ ├── GrouponVO.java
│ │ ├── NewsVO.java
│ │ ├── OrderDetailVO.java
│ │ ├── OrderVO.java
│ │ ├── ProductCategoryVO.java
│ │ ├── ProductVO.java
│ │ ├── SpecificationVO.java
│ │ └── VolunteerInfoVO.java
│ └── resources/
│ ├── application-dev.yml
│ ├── application-prod.yml
│ ├── application-test.yml
│ ├── application.yml
│ ├── banner.txt
│ ├── log4jdbc.properties
│ ├── logback-spring.xml
│ ├── sql/
│ │ ├── all.sql
│ │ ├── cart.sql
│ │ ├── common.sql
│ │ ├── favoriteGoods.sql
│ │ ├── news.sql
│ │ ├── order.sql
│ │ ├── product.sql
│ │ ├── productCategory.sql
│ │ ├── sysConfig.sql
│ │ ├── sysMenu.sql
│ │ └── sysUser.sql
│ ├── static/
│ │ └── swagger/
│ │ ├── css/
│ │ │ ├── print.css
│ │ │ ├── reset.css
│ │ │ ├── screen.css
│ │ │ ├── style.css
│ │ │ └── typography.css
│ │ ├── index.html
│ │ ├── index.yaml
│ │ ├── lang/
│ │ │ ├── en.js
│ │ │ ├── translator.js
│ │ │ └── zh-cn.js
│ │ ├── lib/
│ │ │ ├── backbone-min.js
│ │ │ ├── es5-shim.js
│ │ │ ├── handlebars-4.0.5.js
│ │ │ ├── highlight.9.1.0.pack.js
│ │ │ ├── highlight.9.1.0.pack_extended.js
│ │ │ ├── marked.js
│ │ │ ├── object-assign-pollyfill.js
│ │ │ └── swagger-oauth.js
│ │ ├── o2c.html
│ │ ├── oauth2-redirect.html
│ │ ├── swagger-ui-bundle.js
│ │ ├── swagger-ui-standalone-preset.js
│ │ ├── swagger-ui.css
│ │ └── swagger-ui.js
│ └── templates/
│ ├── hello.html
│ └── success.html
└── test/
└── java/
└── io/
└── sdb/
├── dao/
│ └── SysUserDaoTest.java
├── modules/
│ └── app/
│ └── utils/
│ └── RecordUtilsTest.java
└── service/
└── impl/
├── CartServiceImplTest.java
├── GoodsServiceImplTest.java
├── MailServiceTest.java
├── PayServiceImplTest.java
├── ProductServiceImplTest.java
└── SysLogisticsServiceImplTest.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.js linguist-language=Java
*.css linguist-language=Java
*.html linguist-language=Java
*.* linguist-language=Java
* linguist-language=Java
================================================
FILE: .gitignore
================================================
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
cmake-build-release/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
target/
================================================
FILE: .gitlab-ci.yml
================================================
stages:
- build
- push
- deploy
job1:
stage: build
only:
- dev
tags:
- dev-shell
script:
- echo "build==============="
- mvn -Dmaven.test.skip=true clean package
job2:
stage: push
only:
- dev
tags:
- dev-shell
script:
- echo "push==============="
- mvn docker:push
job3:
stage: deploy
only:
- dev
tags:
- dev-shell
script:
- echo "deploy================"
- cd /docker-swarm
- docker stack deploy -c sdb.yml sdb
#job3:
# stage: deploy
# tags:
# - demo
# script:
# - echo "I am job3"
# - echo "I am in deploy stage"
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "{}" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright 2018 森多邦开源
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# sdb mall
**项目说明**
- sdb是一个轻量级的在renren-fast基础上利用jfinal架构二次开发的一个极速二次开发直播,拼团商城框架,前后端分离的Java快速开发平台,C端采用微信小程序,能快速开发项目并交付【接私活利器】
- 支持MySQL、Oracle、SQL Server、PostgreSQL等主流数据库
- 重点说明:此项目并不是提供下载运行后直接就能上生产的情况,在我多年的经验里告诉我,所有的项目即使是商业模式非常相似但是在业务需求细节上也是有各种各种不同的变化,特别是在C端和campaign这块,举几个例子,在C端方面,你可能和别人使用完全色调,页面布局一模一样的页面吗?在后端同样一个优惠券的功能你能保证你不做一些定制化的实现吗?所以sdb mall这个架构是用来让你可以快速开发成自己独有的,个性化的商城项目,并非是提供大而全的功能,当然我也会在其中添加一些比较通用的功能,比如商城的完整流程和之后会开发一些营销模块等
- 后端开源
**具有如下特点**
- 友好的代码结构及注释,便于阅读及二次开发
- 实现前后端分离,通过token进行数据交互,前端再也不用关注后端技术
- 灵活的权限控制,可控制到页面或按钮,满足绝大部分的权限需求
- 页面交互使用Vue2.x,极大的提高了开发效率
- 完善的代码生成机制,可在线生成entity、xml、dao、service、vue、sql代码,减少70%以上的开发任务
- 引入quartz定时任务,可动态完成任务的添加、修改、删除、暂停、恢复及日志查看等功能
- 引入API模板,根据token作为登录令牌,极大的方便了APP接口开发
- 引入Hibernate Validator校验框架,轻松实现后端校验
- 引入云存储服务,已支持:七牛云、阿里云、腾讯云等
- 引入swagger文档支持,方便编写API接口文档
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.sdb.common.utils;
import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 日期处理
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年12月21日 下午12:53:33
*/
public class DateUtils {
/** 时间格式(yyyy-MM-dd) */
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**
* 日期格式化 日期格式为:yyyy-MM-dd
* @param date 日期
* @return 返回yyyy-MM-dd格式日期
*/
public static String format(Date date) {
return format(date, DATE_PATTERN);
}
/**
* 日期格式化 日期格式为:yyyy-MM-dd
* @param date 日期
* @param pattern 格式,如:DateUtils.DATE_TIME_PATTERN
* @return 返回yyyy-MM-dd格式日期
*/
public static String format(Date date, String pattern) {
if(date != null){
SimpleDateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
}
return null;
}
/**
* 字符串转换成日期
* @param strDate 日期字符串
* @param pattern 日期的格式,如:DateUtils.DATE_TIME_PATTERN
*/
public static Date stringToDate(String strDate, String pattern) {
if (StringUtils.isBlank(strDate)){
return null;
}
DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
return fmt.parseLocalDateTime(strDate).toDate();
}
/**
* 根据周数,获取开始日期、结束日期
* @param week 周期 0本周,-1上周,-2上上周,1下周,2下下周
* @return 返回date[0]开始日期、date[1]结束日期
*/
public static Date[] getWeekStartAndEnd(int week) {
DateTime dateTime = new DateTime();
LocalDate date = new LocalDate(dateTime.plusWeeks(week));
date = date.dayOfWeek().withMinimumValue();
Date beginDate = date.toDate();
Date endDate = date.plusDays(6).toDate();
return new Date[]{beginDate, endDate};
}
/**
* 对日期的【秒】进行加/减
*
* @param date 日期
* @param seconds 秒数,负数为减
* @return 加/减几秒后的日期
*/
public static Date addDateSeconds(Date date, int seconds) {
DateTime dateTime = new DateTime(date);
return dateTime.plusSeconds(seconds).toDate();
}
/**
* 对日期的【分钟】进行加/减
*
* @param date 日期
* @param minutes 分钟数,负数为减
* @return 加/减几分钟后的日期
*/
public static Date addDateMinutes(Date date, int minutes) {
DateTime dateTime = new DateTime(date);
return dateTime.plusMinutes(minutes).toDate();
}
/**
* 对日期的【小时】进行加/减
*
* @param date 日期
* @param hours 小时数,负数为减
* @return 加/减几小时后的日期
*/
public static Date addDateHours(Date date, int hours) {
DateTime dateTime = new DateTime(date);
return dateTime.plusHours(hours).toDate();
}
/**
* 对日期的【天】进行加/减
*
* @param date 日期
* @param days 天数,负数为减
* @return 加/减几天后的日期
*/
public static Date addDateDays(Date date, int days) {
DateTime dateTime = new DateTime(date);
return dateTime.plusDays(days).toDate();
}
/**
* 对日期的【周】进行加/减
*
* @param date 日期
* @param weeks 周数,负数为减
* @return 加/减几周后的日期
*/
public static Date addDateWeeks(Date date, int weeks) {
DateTime dateTime = new DateTime(date);
return dateTime.plusWeeks(weeks).toDate();
}
/**
* 对日期的【月】进行加/减
*
* @param date 日期
* @param months 月数,负数为减
* @return 加/减几月后的日期
*/
public static Date addDateMonths(Date date, int months) {
DateTime dateTime = new DateTime(date);
return dateTime.plusMonths(months).toDate();
}
/**
* 对日期的【年】进行加/减
*
* @param date 日期
* @param years 年数,负数为减
* @return 加/减几年后的日期
*/
public static Date addDateYears(Date date, int years) {
DateTime dateTime = new DateTime(date);
return dateTime.plusYears(years).toDate();
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/EnumUtil.java
================================================
package io.sdb.common.utils;
import io.sdb.enums.IEnum;
public class EnumUtil {
public static T getByCode(Integer code, Class enumClass) {
for (T each: enumClass.getEnumConstants()) {
if (code.equals(each.getCode())) {
return each;
}
}
return null;
}
public static T getByMsg(String msg, Class enumClass) {
for (T each: enumClass.getEnumConstants()) {
if (msg.equalsIgnoreCase(each.getMessage())) {
return each;
}
}
return null;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/GenericsUtils.java
================================================
package io.sdb.common.utils;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class GenericsUtils {
/**
* 通过反射,获得定义Class时声明的父类的范型参数的类型.
* 如public BookManager extends GenricManager
*
* @param clazz The class to introspect
* @return the first generic declaration, or Object.class if cannot be determined
*/
public static Class getSuperClassGenricType(Class clazz) {
return getSuperClassGenricType(clazz, 0);
}
/**
* 通过反射,获得定义Class时声明的父类的范型参数的类型.
* 如public BookManager extends GenricManager
*
* @param clazz clazz The class to introspect
* @param index the Index of the generic ddeclaration,start from 0.
*/
public static Class getSuperClassGenricType(Class clazz, int index) throws IndexOutOfBoundsException {
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
return Object.class;
}
if (!(params[index] instanceof Class)) {
return Object.class;
}
return (Class) params[index];
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/HttpContextUtils.java
================================================
package io.sdb.common.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
public class HttpContextUtils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
public static String getDomain(){
HttpServletRequest request = getHttpServletRequest();
StringBuffer url = request.getRequestURL();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString();
}
public static String getOrigin(){
HttpServletRequest request = getHttpServletRequest();
return request.getHeader("Origin");
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/HttpRequest.java
================================================
package io.sdb.common.utils;
import com.jfinal.kit.LogKit;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class HttpRequest {
public static String addUrl(String head, String tail) {
if (head.endsWith("/")) {
if (tail.startsWith("/")) {
return head.substring(0, head.length() - 1) + tail;
} else {
return head + tail;
}
} else {
if (tail.startsWith("/")) {
return head + tail;
} else {
return head + "/" + tail;
}
}
}
public synchronized static String postData(String url, Map params) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
//拼接参数
List nvps = new ArrayList();
NameValuePair[] nameValuePairArray = assembleRequestParams(params);
for (NameValuePair value:nameValuePairArray
) {
nvps.add(value);
}
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
CloseableHttpResponse response = httpclient.execute(httpPost);
String result = "";
try {
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
// do something useful with the response body
if (entity != null) {
result = EntityUtils.toString(entity, "UTF-8");
}else{
LogKit.error("httpRequest postData1 error entity = null code = "+statusLine.getStatusCode());
}
// and ensure it is fully consumed
//消耗掉response
EntityUtils.consume(entity);
} finally {
response.close();
}
return result;
}
public synchronized static String postData(String url) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
CloseableHttpResponse response = httpclient.execute(httpPost);
String result = "";
try {
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
// do something useful with the response body
if (entity != null) {
result = EntityUtils.toString(entity, "UTF-8");
}else{
LogKit.error("httpRequest postData2 error entity = null code = "+statusLine.getStatusCode());
}
// and ensure it is fully consumed
//消耗掉response
EntityUtils.consume(entity);
} finally {
response.close();
}
return result;
}
/**
* 组装http请求参数
* @return
*/
private synchronized static NameValuePair[] assembleRequestParams(Map data) {
final List nameValueList = new ArrayList();
Iterator> it = data.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
nameValueList.add(new BasicNameValuePair((String) entry.getKey(), (String) entry.getValue()));
}
return nameValueList.toArray(new NameValuePair[nameValueList.size()]);
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/IPUtils.java
================================================
package io.sdb.common.utils;
import com.alibaba.druid.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
/**
* IP地址
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017年3月8日 下午12:57:02
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);
/**
* 获取IP地址
*
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} catch (Exception e) {
logger.error("IPUtils ERROR ", e);
}
// //使用代理,则获取第一个IP地址
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
// if(ip.indexOf(",") > 0) {
// ip = ip.substring(0, ip.indexOf(","));
// }
// }
return ip;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/JfEnjoy.java
================================================
package io.sdb.common.utils;
import com.jfinal.kit.Kv;
import com.jfinal.kit.PathKit;
import com.jfinal.template.Engine;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class JfEnjoy {
/**
* 根据具体魔板生成文件
* @param templateFileName 模板文件名称
* @param kv 渲染参数
* @param filePath 输出目录
* @return
*/
public boolean render(String templateFileName, Kv kv, StringBuilder filePath) {
BufferedWriter output = null;
try {
String baseTemplatePath = new StringBuilder(PathKit.getWebRootPath())
.append("/src/main/java/")
.append(PathKit.getPackagePath(this))
.append("/tpl")
.toString();
File file = new File(filePath.toString());
if(file.exists()){
return true;
}
File path = new File(file.getParent());
if ( ! path.exists() ) {
path.mkdirs();
}
output = new BufferedWriter(new FileWriter(file));
Engine.use()
.setBaseTemplatePath(baseTemplatePath)
.getTemplate(templateFileName)
.render(kv, output);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}finally{
try { if( output != null ) output.close(); } catch (IOException e) {}
}
}
/**
* 根据自定义内容生成文件
* @param data 自定义内容
* @param filePath 输出目录
* @return
*/
public boolean render(String data, StringBuilder filePath) {
BufferedWriter output = null;
try {
File file = new File(filePath.toString());
File path = new File(file.getParent());
if ( ! path.exists() ) {
path.mkdirs();
}
output = new BufferedWriter(new FileWriter(file));
output.write(data);
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}finally{
try { if( output != null ) output.close(); } catch (IOException e) {}
}
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/JsonUtils.java
================================================
package io.sdb.common.utils;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* @author Binary Wang
*/
public class JsonUtils {
private static final ObjectMapper JSON = new ObjectMapper();
static {
JSON.setSerializationInclusion(Include.NON_NULL);
JSON.configure(SerializationFeature.INDENT_OUTPUT, Boolean.TRUE);
}
public static String toJson(Object obj) {
try {
return JSON.writeValueAsString(obj);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/JwtUtils.java
================================================
package io.sdb.common.utils;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* jwt工具类
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017/9/21 22:21
*/
@ConfigurationProperties(prefix = "sdb.jwt")
@Component
public class JwtUtils {
private Logger logger = LoggerFactory.getLogger(getClass());
private String secret;
private long expire;
private String header;
/**
* 生成jwt token
*/
public String generateToken(String userId) {
Date nowDate = new Date();
//过期时间
Date expireDate = new Date(nowDate.getTime() + expire * 1000);
return Jwts.builder()
.setHeaderParam("typ", "JWT")
.setSubject(userId+"")
.setIssuedAt(nowDate)
.setExpiration(expireDate)
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
}
public Claims getClaimByToken(String token) {
try {
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
}catch (Exception e){
logger.debug("validate is token error ", e);
return null;
}
}
/**
* token是否过期
* @return true:过期
*/
public boolean isTokenExpired(Date expiration) {
return expiration.before(new Date());
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public long getExpire() {
return expire;
}
public void setExpire(long expire) {
this.expire = expire;
}
public String getHeader() {
return header;
}
public void setHeader(String header) {
this.header = header;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/MapUtils.java
================================================
/**
* Copyright 2018
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.sdb.common.utils;
import java.util.HashMap;
/**
* Map工具类
*
* @author Mark sunlightcs@gmail.com
* @since 2.0.0
*/
public class MapUtils extends HashMap {
@Override
public MapUtils put(String key, Object value) {
super.put(key, value);
return this;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/MoneyUtils.java
================================================
package io.sdb.common.utils;
public class MoneyUtils {
/**
* 数字金额大写转换,思想先写个完整的然后将如零拾替换成零 要用到正则表达式
*/
public static String digitUppercase(double n) {
String fraction[] = {"角", "分"};
String digit[] = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
String unit[][] = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
String head = n < 0 ? "负" : "";
n = Math.abs(n);
String s = "";
for (int i = 0; i < fraction.length; i++) {
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
}
if (s.length() < 1) {
s = "整";
}
int integerPart = (int) Math.floor(n);
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
String p = "";
for (int j = 0; j < unit[1].length && n > 0; j++) {
p = digit[integerPart % 10] + unit[1][j] + p;
integerPart = integerPart / 10;
}
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
}
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
}
private void number2Invoice(int num) {
//12345
String mark[] = new String[]{"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万"};
String numCn[] = new String[]{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
char[] numArrRev = String.valueOf(num).toCharArray();
StringBuffer container = new StringBuffer();
for (int i = 0; i < numArrRev.length; i++) {
Integer val = Integer.valueOf(String.valueOf(numArrRev[i]));
String number = numCn[val];
int x = numArrRev.length - i - 1;
String sign = mark[x];
if (val == 0) {
if (x % 4 != 0) {// 删除单位
sign = "";
}
if (i < numArrRev.length - 1) {
Integer val1 = Integer.parseInt(String.valueOf(numArrRev[i + 1]));
if (val == 0 && val == val1) {
number = "";
} else if (val == 0 && ("万".equals(sign) || "亿".equals(sign))) {
number = "";
}
} else if (i == numArrRev.length - 1) {
number = "";
}
}
container.append(number + sign);
}
System.out.println(num + "-->" + container.toString());
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/PageUtils.java
================================================
/**
* Copyright 2018
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.sdb.common.utils;
import java.io.Serializable;
import java.util.List;
/**
* 分页工具类
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年11月4日 下午12:59:00
*/
public class PageUtils implements Serializable {
private static final long serialVersionUID = 1L;
//总记录数
private int totalCount;
//每页记录数
private int pageSize;
//总页数
private int totalPage;
//当前页数
private int currPage;
//列表数据
private List> list;
/**
* 分页
* @param list 列表数据
* @param totalCount 总记录数
* @param pageSize 每页记录数
* @param currPage 当前页数
*/
public PageUtils(List> list, int totalCount, int pageSize, int currPage) {
this.list = list;
this.totalCount = totalCount;
this.pageSize = pageSize;
this.currPage = currPage;
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
}
/**
* 分页
*/
public PageUtils(com.jfinal.plugin.activerecord.Page> page) {
this.list = page.getList();
this.totalCount = page.getTotalRow();
this.pageSize = page.getPageSize();
this.currPage = page.getPageNumber();
this.totalPage = page.getTotalPage();
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getCurrPage() {
return currPage;
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public List> getList() {
return list;
}
public void setList(List> list) {
this.list = list;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/Query.java
================================================
/**
* Copyright 2018
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.sdb.common.utils;
import io.sdb.common.xss.SQLFilter;
import io.sdb.common.entity.Order;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 查询参数
*
* @author Mark sunlightcs@gmail.com
* @since 2.0.0 2017-03-14
*/
@Data
public class Query extends LinkedHashMap {
private static final long serialVersionUID = 1L;
/**
* 当前页码
*/
private int currPage = 1;
/**
* 每页条数
*/
private int limit = 10;
private Order order;
public Query(Map params){
this.putAll(params);
//分页参数
if(params.get("page") != null){
currPage = Integer.parseInt((String)params.get("page"));
}
if(params.get("limit") != null){
limit = Integer.parseInt((String)params.get("limit"));
}
this.put("offset", (currPage - 1) * limit);
this.put("page", currPage);
this.put("limit", limit);
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
String sidx = SQLFilter.sqlInject((String)params.get("sidx"));
String strOrder = SQLFilter.sqlInject((String)params.get("order"));
this.put("sidx", sidx);
this.put("order", strOrder);
//排序
if(StringUtils.isNotBlank(sidx) && StringUtils.isNotBlank(strOrder)){
order = new Order();
order.setProperty(sidx);
order.setDirection("ASC".equalsIgnoreCase(strOrder)? Order.Direction.asc: Order.Direction.desc);
}
}
public int getCurrPage() {
return currPage;
}
public int getLimit() {
return limit;
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/R.java
================================================
package io.sdb.common.utils;
import io.sdb.enums.ResultEnum;
import org.apache.http.HttpStatus;
import java.util.HashMap;
import java.util.Map;
/**
* 返回数据
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2016年10月27日 下午9:59:27
*/
public class R extends HashMap {
private static final long serialVersionUID = 1L;
public R() {
put("code", 0);
put("msg", "success");
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
public static R error(int code, String msg) {
R r = new R();
r.put("code", code);
r.put("msg", msg);
return r;
}
public static R ok(String msg) {
R r = new R();
r.put("msg", msg);
return r;
}
public static R ok(Map map) {
R r = new R();
r.putAll(map);
return r;
}
public static R ok() {
return new R();
}
public R put(String key, Object value) {
super.put(key, value);
return this;
}
public static R error(ResultEnum resultEnum){
return error(resultEnum.getCode(), resultEnum.getMessage());
}
}
================================================
FILE: src/main/java/io/sdb/common/utils/RecordUtils.java
================================================
package io.sdb.common.utils;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class RecordUtils {
private static final Logger logger = LoggerFactory.getLogger(RecordUtils.class);
/**
* Record 转 任意实例类
*
* @param record
* @return
*/
public static T converModel(Record record, Class clazz) {
String str = JSON.toJSONString(record.getColumns());
T obj = JSON.parseObject(str, clazz);
return obj;
}
/**
* Record 转 任意实例类
*
* @param recordList
* @return
*/
public static List converModel(List recordList, Class clazz) {
List