diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..36de67a3 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: houko +patreon: #hupeng +open_collective: SpringBootUnity +ko_fi: #hupeng +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: #houko/SpringBootUnity +otechie: # Replace with a single Otechie username +custom: #https:blog.xiaomo.info diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..1620e2e5 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,72 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '24 7 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # i️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.travis.yml b/.travis.yml index dff5f3a5..34d145f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,4 @@ language: java +jdk: + - oraclejdk11 +dist: trusty \ No newline at end of file diff --git a/LICENSE b/LICENSE index 43ce4f3e..2d703922 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,21 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - CopyRight (c) 2017 小莫 - - 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: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) 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 - - (d) 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 {yyyy} {name of copyright owner} - - 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. +MIT License + +Copyright (c) 2017 Peng Hu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/Readme.md similarity index 61% rename from README.md rename to Readme.md index a69c5061..6f137c59 100644 --- a/README.md +++ b/Readme.md @@ -1,40 +1,39 @@ -[![Build Status](https://travis-ci.org/xiaomoinfo/SpringBootUnity.svg?branch=master)](https://travis-ci.org/xiaomoinfo/SpringBootUnity) -[![Backers on Open Collective](https://opencollective.com/SpringBootUnity/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/SpringBootUnity/sponsors/badge.svg)](#sponsors) [![GitHub issues](https://img.shields.io/github/issues/xiaomoinfo/SpringBootUnity.svg)](https://github.com/xiaomoinfo/SpringBootUnity/issues) -[![GitHub forks](https://img.shields.io/github/forks/xiaomoinfo/SpringBootUnity.svg)](https://github.com/xiaomoinfo/SpringBootUnity/network) -[![GitHub stars](https://img.shields.io/github/stars/xiaomoinfo/SpringBootUnity.svg)](https://github.com/xiaomoinfo/SpringBootUnity/stargazers) -[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/xiaomoinfo/MysqlBlobToJsonTool/master/LICENSE) +[![Build Status](https://travis-ci.org/houko/SpringBootUnity.svg?branch=master)](https://travis-ci.org/houko/SpringBootUnity) +[![Backers on Open Collective](https://opencollective.com/SpringBootUnity/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/SpringBootUnity/sponsors/badge.svg)](#sponsors) [![GitHub issues](https://img.shields.io/github/issues/houko/SpringBootUnity.svg)](https://github.com/houko/SpringBootUnity/issues) +[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/houko/SpringBootUnity/master/LICENSE) [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven/apache-maven.svg)]() -[![GitHub followers](https://img.shields.io/github/followers/xiaomoinfo.svg?style=social&label=Follow)]() ### 项目简介 -![mark](screenshot/spring.png) +![mark](screenshot/SpringBootUnity.png) ### 环境 - `maven` latest -- `jdk1.8` -- `spring boot 1.5.6 release`(目前最新版) -- 个人推荐`idea`来代替eclipse(希望不要被说成异教徒必须死) -- mysql5.5+ +- `jdk11` +- `spring boot 2.x release` +- 个人推荐`idea`来代替eclipse - git: 版本管理 - nginx: 反向代理服务器 -- lombok - ### 注意事项 -- 本项目代码托管在[github](https://github.com/xiaomoinfo/SpringBootUnity)和[码云](http://git.oschina.net/hupeng/SpringBootUnity)两个地方,最新代码以github为准,码云上会在github上更新完之后进行同步。 +- 本项目代码托管在[github](https://github.com/houko/SpringBootUnity)和[码云](http://git.oschina.net/hupeng_admin/SpringBootUnity)两个地方,最新代码会先推送在github上,码云上会在github上更新完之后进行同步。 - 本项目多数数据库都用到了`hibernate`,如果没有提供`sql`文件。则启动时会根据代码映射自动生成数据库表,请在启动前修改`application.properties`中的数据库连接信息 -- 本项目使用了`lombok`,在查看本项目时如果您没有下载`lombok 插件`,请先安装,不然找不到`get/set`方法。eclipse用户请参照[官网](http://jnb.ociweb.com/jnb/jnbJan2010.html#references) - -![lombok](screenshot/lombok.png) ### 启动方式 -- `spring boot`内置了tomcat做为web容器,默认打成jar包直接放在服务器上执行就可以了 + +- 本地运行 +本repo是一个多模块组成,每一个模块都可以单独打包运行。如果想运行哪个模块可以找到对应的Main文件右键运行。 +![run](screenshot/run.png) + + +- 在linux服务器运行 + `spring boot`内置了tomcat做为web容器,默认打成jar包直接放在服务器上执行就可以了 > `java -Xms64m -Xmx2048m -jar project.jar 5>> ./project.log &` -![jar](https://static.xiaomo.info/image/project/javajar.gif) + +### 打包 - 如果需要定制化打成war包,那么也很简单。在`maven`中做下设置就ok了,然后把war包扔到tomcat下面就可以运行了 ``` @@ -45,13 +44,11 @@ ### 更新日志 -由于更新日志占用篇幅太多,单独用一个文件存放。链接地址 [更新日志(详细)](/changeLog.md),这里只展示更新简介 - - 2017年09月02日 api模块: 添加swagger-bootstrap-ui,和原有ui并行存在。 http://localhost:8080 默认UI http://localhost:808/doc.html bootstrap-ui -- 2017年09月02日 spring boot版本从1.4.3更新到1.5.6 +- 2017年09月02日 spring boot版本从1.4.3更新到1.5.8 - 2017年09月02日 修复不配置数据库信息无法启动的bug - 2017年09月02日 版本号更新到2017.1 - 2017年09月02日 api模块(swagger)添加开源库swagger-bootstrap-ui,和swagger默认UI同时存在。 @@ -60,52 +57,24 @@ http://localhost:808/doc.html bootstrap-ui - 2017年09月06日 所有模块: 添加 characterEncoding=utf8&useSSL=true 解决高版本mysql的sll警告 - 2017年09月06日 添加代码贡献者列表和支持者,赞助商链接。 - 2017年09月08日 crawler模块(网络爬虫):修复本地文件目录不存在会报错的bug。处理方式为:不存在则自动创建 +- 2017年11月02日 开源协议从apache更换到MIT +- 2017年11月02日 添加本地运行方式的说明 +- 2017年11月02日 版本更新到2020.1 +- 2017年11月02日 spring boot版本更新到1.5.8 +- 2017年11月03日 添加kotlin环境配置 +- 2017年11月03日 按照阿里巴巴编程规范插件P3C优化代码 +- 2017年11月03日 合并`api`和`website`模块,访问`localhost:8080`会显示网站主页,访问`localhost:8080/api`会显示api管理界面 +- 2018年04月09日 将整个项目升级到spring boot2.0 release版本,api有较大变动 +- 2019年08月06日 travis-ci指定jdk版本 +- 2020年10月09日 升级版本到2020.2 +- 2020年10月09日 升级jdk版本到11 +- 2020年10月09日 升级mysql connector到8 +- 2020年10月09日 升级spring boot到2.3.0 +- 2020年10月09日 修复了升级后API的破坏性变动,修复了一些了编辑器警告 -### 项目说明 -需求是多变的,本项目是以spring boot为基础,在使用spring boot的过程中对应不同的需求选用不同的技术和spring boot进行搭配,因此本项目是个偏于使用示例的定位。同时如果您在使用spring boot的过程中有什么好用的技术期待您对本项目的PR。 - -### 关于我 - @[小莫](https://xiaomo.info):本人是一个热爱开源精神、追求新潮的开发者,技术过得去,还算勤勉!习惯以github的issue驱动方式来组织我的项目,也希望感兴趣的朋友和我联系,一起进步,共同开发感兴趣的开源项目。目前任rpg服务端主程,熟悉游戏开发和web开发。同时也是个喜欢二次元的死宅,爱动漫,略懂日语。 - -### 在线小工具 - -- [在线Cron表达式生成器](http://cron.qqe2.com/ "在线Cron表达式生成器") - -- [在线工具 - 程序员的工具箱](http://tool.lu/ "在线工具 - 程序员的工具箱") - - -### 问题反馈 -1. 欢迎提[issue](https://github.com/xiaomoinfo/SpringBootUnity/issues)一起完善这个项目。 -2. QQ: 83387856 -4. 个人主站: https://xiaomo.info - -### 在线文档 - -- [JDK7英文文档](http://tool.oschina.net/apidocs/apidoc?api=jdk_7u4 "JDK7英文文档") - -- [Spring4.x文档](http://spring.oschina.mopaas.com/ "Spring4.x文档") - -- [Mybatis3官网](http://www.mybatis.org/mybatis-3/zh/index.html "Mybatis3官网") - -- [Dubbo官网](http://dubbo.io/ "Dubbo官网") - -- [Nginx中文文档](http://tool.oschina.net/apidocs/apidoc?api=nginx-zh "Nginx中文文档") - -- [Freemarker在线手册](http://freemarker.foofun.cn/ "Freemarker在线中文手册") - -- [Velocity在线手册](http://velocity.apache.org/engine/devel/developer-guide.html "Velocity在线手册") - -- [Bootstrap在线手册](http://www.bootcss.com/ "Bootstrap在线手册") - -- [Git官网中文文档](https://git-scm.com/book/zh/v2 "Git官网中文文档") - -- [Thymeleaf](http://www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html "Thymeleaf") - - - ## 贡献者 感谢所有为本项目做出贡献的开发者们. @@ -134,19 +103,47 @@ http://localhost:808/doc.html bootstrap-ui +### 项目说明 +需求是多变的,本项目是以spring boot为基础,在使用spring boot的过程中对应不同的需求选用不同的技术和spring boot进行搭配,因此本项目是个偏于使用示例的定位。同时如果您在使用spring boot的过程中有什么好用的技术期待您对本项目的PR。 +### 关于我 + @[小莫](https://xiaomo.info):本人是一个热爱开源精神、追求新潮的开发者,技术过得去,还算勤勉!习惯以github的issue驱动方式来组织我的项目,也希望感兴趣的朋友和我联系,一起进步,共同开发感兴趣的开源项目。目前任rpg服务端主程,熟悉游戏开发和web开发。同时也是个喜欢二次元的死宅,爱动漫,略懂日语。 + +### 在线小工具 + +- [在线Cron表达式生成器](http://cron.qqe2.com/ "在线Cron表达式生成器") -## [License](LICENSE "apache") +- [在线工具 - 程序员的工具箱](http://tool.lu/ "在线工具 - 程序员的工具箱") +- [spring boot官方脚手架](https://start.spring.io/ "spring boot官方脚手架") + + +### 问题反馈 +1. 欢迎提[issue](https://github.com/houko/SpringBootUnity/issues)一起完善这个项目。 +2. QQ: 83387856 +4. 个人主站: https://xiaomo.info - Copyright 2017 xiaomo - 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 +## [License](LICENSE "MIT") + + MIT License + + Copyright (c) 2022 Peng Hu + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. - 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. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..034e8480 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index 0847531b..00000000 --- a/api/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.idea -*.iml -node_modules -target \ No newline at end of file diff --git a/api/README.md b/api/README.md deleted file mode 100644 index 9c7badfd..00000000 --- a/api/README.md +++ /dev/null @@ -1 +0,0 @@ -API接口 \ No newline at end of file diff --git a/api/src/main/java/info/xiaomo/api/controller/AdminUserController.java b/api/src/main/java/info/xiaomo/api/controller/AdminUserController.java deleted file mode 100644 index 1f105f63..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/AdminUserController.java +++ /dev/null @@ -1,357 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.AdminModel; -import info.xiaomo.api.service.AdminUserService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import info.xiaomo.core.exception.UserNotFoundException; -import info.xiaomo.core.untils.MD5Util; -import info.xiaomo.core.untils.RandomUtil; -import io.swagger.annotations.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 12:47 - * Description: 后台用户控制器 - * Copyright(©) 2015 by xiaomo. - */ -@RestController -@RequestMapping("/adminUser") -@Api(value = "后台用户相关api", description = "后台用户相关api") -public class AdminUserController extends BaseController { - - private final AdminUserService service; - - @Autowired - public AdminUserController(AdminUserService service) { - this.service = service; - } - - /** - * 后台账户登录 - * - * @return Result - */ - @RequestMapping(value = "login/{userName}/{password}", method = RequestMethod.POST) - @ApiOperation(value = "获取用户信息", notes = "根据用户帐号和密码登录后台", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "Result", paramType = "path"), - @ApiImplicitParam(name = "password", value = "用户名", required = true, dataType = "Result", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result login(@PathVariable("userName") String userName, @PathVariable("password") String password) { - AdminModel adminModel = service.findAdminUserByUserName(userName); - if (adminModel == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - if (!MD5Util.encode(password, adminModel.getSalt()).equals(adminModel.getPassword())) { - return new Result(CodeConst.AUTH_FAILED.getResultCode(), CodeConst.AUTH_FAILED.getMessage()); - } - return new Result(adminModel); - } - - - /** - * 添加用户 - * - * @return Result - */ - @ApiOperation(value = "添加后台用户", notes = "传一个管理员用户模型过来然后保存到数据库", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "add", method = RequestMethod.POST) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result add(@RequestBody AdminModel model) { - AdminModel adminModel = service.findAdminUserByUserName(model.getUserName()); - if (adminModel != null) { - return new Result(CodeConst.ADMIN_USER_REPEAT.getResultCode(), CodeConst.ADMIN_USER_REPEAT.getMessage()); - } - String salt = RandomUtil.createSalt(); - model.setSalt(salt); - model.setPassword(MD5Util.encode(model.getPassword(), salt)); - AdminModel saveModel = service.addAdminUser(model); - return new Result(saveModel); - } - - /** - * 根据id查找 - * - * @param id id - * @return Result - */ - @ApiOperation(value = "查找用户", notes = "根据传来的id查找用户并返回", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "findById/{id}", method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "后台用户唯一id", required = true, dataType = "Long", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result findUserById(@PathVariable("id") Long id) { - AdminModel adminModel = service.findAdminUserById(id); - if (adminModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(adminModel); - } - - /** - * 查找所有(不带分页) - * - * @return result - */ - @Override - public Result findAll() { - return null; - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - /** - * 根据id查看模型 - * - * @param id id - * @return result - */ - @Override - public Result findById(@PathVariable Long id) { - return null; - } - - /** - * 根据名字查找 - * - * @param userName userName - * @return Result - */ - @ApiOperation(value = "查找用户", notes = "根据传来的用户名查找用户并返回", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "findByName/{userName}", method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result findByName(@PathVariable("userName") String userName) { - AdminModel adminModel = service.findAdminUserByUserName(userName); - if (adminModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(adminModel); - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - /** - * 修改密码 - * - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @RequestMapping(value = "changePassword", method = RequestMethod.POST) - @ApiOperation(value = "修改用户密码", notes = "传来模型验证并修改密码", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result changePassword(@RequestBody AdminModel model) throws UserNotFoundException { - AdminModel adminModel = service.findAdminUserByUserName(model.getUserName()); - if (adminModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - String salt = RandomUtil.createSalt(); - adminModel.setSalt(salt); - adminModel.setPassword(MD5Util.encode(model.getPassword(), salt)); - service.updateAdminUser(adminModel); - return new Result(adminModel); - } - - - /** - * 返回所有 - * - * @return 不分页 - */ - @RequestMapping(value = "findAll", method = RequestMethod.GET) - @ApiOperation(value = "返回所有用户信息", notes = "不分页", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result getAll() { - List pages = service.getAdminUsers(); - if (pages == null || pages.size() <= 0) { - return new Result(pages); - } - return new Result(pages); - } - - /** - * 根据id删除数据 - * - * @param id id - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @RequestMapping(value = "delete/{id}", method = RequestMethod.GET) - @ApiOperation(value = "删除用户", notes = "根据传入的id删除对应的用户", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "用户唯一id", required = true, dataType = "Long", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundException { - AdminModel adminModel = service.findAdminUserById(id); - if (adminModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - service.deleteAdminUserById(id); - return new Result(adminModel); - } - - /** - * 更新 - * - * @param userName userName - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @RequestMapping(value = "update/{userName}", method = RequestMethod.POST) - @ApiOperation(value = "更新用户信息", notes = "根据传入的模型更新用户信息", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "userName", value = "用户名", required = true, dataType = "String", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result update(@PathVariable("userName") String userName) throws UserNotFoundException { - AdminModel adminModel = service.findAdminUserByUserName(userName); - if (adminModel == null) { - return null; - } - adminModel.setUserName(userName); - service.updateAdminUser(adminModel); - return new Result(adminModel); - } - - /** - * 封号 - * - * @param id id - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @RequestMapping(value = "forbid/{id}", method = RequestMethod.GET) - @ApiOperation(value = "封号", notes = "根据传入的id对修改对应帐号状态", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "后台用户唯一id", required = true, dataType = "Long", paramType = "path") - }) - @ApiResponses(value = { - @ApiResponse(code = 404, message = "Not Found"), - @ApiResponse(code = 400, message = "No Name Provided"), - }) - public Result forbid(@PathVariable("id") Long id) throws UserNotFoundException { - AdminModel model = service.findAdminUserById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - model = service.forbidAdminUserById(id); - return new Result(model); - } -} - diff --git a/api/src/main/java/info/xiaomo/api/controller/ChangeLogController.java b/api/src/main/java/info/xiaomo/api/controller/ChangeLogController.java deleted file mode 100644 index 7c50499a..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/ChangeLogController.java +++ /dev/null @@ -1,221 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.ChangeLogModel; -import info.xiaomo.api.service.ChangeLogService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1117:40 - * Description: 更新日志控制器 - * Copyright(©) 2015 by xiaomo. - **/ -@RestController -@RequestMapping("/changeLog") -@Api(value = "更新日志相关api",description = "更新日志相关api") -public class ChangeLogController extends BaseController { - - private final ChangeLogService service; - - @Autowired - public ChangeLogController(ChangeLogService service) { - this.service = service; - } - - /** - * 通过id查找 - * - * @param id id - * @return model - */ - @RequestMapping(value = "findById/{id}",method = RequestMethod.GET) - @ApiOperation(value = "通过id查找", notes = "通过id查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path") - }) - public Result findById(@PathVariable("id") Long id) { - ChangeLogModel changeLogModel = service.findById(id); - if (changeLogModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(changeLogModel); - } - - /** - * findByName - * - * @return result - */ - @RequestMapping(value = "findByName/{name}", method = RequestMethod.GET) - @ApiOperation(value = "通过名字查找", notes = "通过名字查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "更新日志内容", required = true, dataType = "String", paramType = "path") - }) - public Result findByName( @PathVariable("name") String name) { - ChangeLogModel model = service.findByName(name); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - /** - * 分页查询更新日志 - * - * @return 分页 - */ - @RequestMapping(value = "findAll", method = RequestMethod.GET) - @ApiOperation(value = "分页查询更新日志", notes = "分页查询更新日志",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Result findAll() { - List pages = service.findAll(); - if (pages == null || pages.size() <= 0) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(pages); - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - /** - * 增加更新日志 - * - * @return result - */ - @ApiOperation(value = "增加更新日志", notes = "增加更新日志",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "add", method = RequestMethod.POST) - public Result add(@RequestBody ChangeLogModel model) { - ChangeLogModel changeLogModel = service.findByName(model.getName()); - if (changeLogModel != null) { - return new Result(CodeConst.REPEAT.getResultCode(), CodeConst.REPEAT.getMessage()); - } - changeLogModel = new ChangeLogModel(); - changeLogModel.setName(model.getName()); - changeLogModel.setOnlineTime(model.getOnlineTime()); - ChangeLogModel addModel = service.add(changeLogModel); - return new Result(addModel); - } - - - /** - * 修改更新日志 - * - * @return result - */ - @ApiOperation(value = "修改更新日志", notes = "修改更新日志",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "update", method = RequestMethod.POST) - public Result update(@RequestBody ChangeLogModel model) { - ChangeLogModel changeLogModel = service.findByName(model.getName()); - if (changeLogModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - changeLogModel.setName(model.getName()); - changeLogModel.setOnlineTime(model.getOnlineTime()); - ChangeLogModel updateModel = service.update(changeLogModel); - return new Result(updateModel); - } - - - /** - * 删除更新日志 - */ - @RequestMapping(value = "delete/{id}", method = RequestMethod.GET) - @ApiOperation(value = "删除更新日志", notes = "删除更新日志",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path") - }) - public Result deleteById(@PathVariable("id") Long id) { - ChangeLogModel changeLogModel = service.findById(id); - if (changeLogModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - ChangeLogModel delModel = service.delete(id); - return new Result(delModel); - } - - -} diff --git a/api/src/main/java/info/xiaomo/api/controller/LinkController.java b/api/src/main/java/info/xiaomo/api/controller/LinkController.java deleted file mode 100644 index 512abcc2..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/LinkController.java +++ /dev/null @@ -1,251 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.LinkModel; -import info.xiaomo.api.service.LinkService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:55 - * Description: 友情连接控制器 - * Copyright(©) 2015 by xiaomo. - **/ -@RestController -@RequestMapping("/link") -@Api(value = "友情链接相关api",description = "友情链接相关api") -public class LinkController extends BaseController { - - private final LinkService service; - - @Autowired - public LinkController(LinkService service) { - this.service = service; - } - - /** - * 根据id查找 - * - * @param id id - * @return model - */ - @RequestMapping(value = "findById/{id}",method = RequestMethod.GET) - @ApiOperation(value = "通过id查找", notes = "通过id查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path") - }) - public Result findLinkById(@PathVariable("id") Long id) { - LinkModel model = service.findById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - /** - * 根据名字查找 - * - * @param name name - * @return model - */ - @RequestMapping(value = "findByName/{name}",method = RequestMethod.GET) - @ApiOperation(value = "根据名字查找", notes = "根据名字查找",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "友情链接名字", required = true, dataType = "String", paramType = "path") - }) - public Result findByName(@PathVariable("name") String name) { - LinkModel model = service.findByName(name); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - - /** - * 返回所有数据 - * - * @return 所有 - */ - @RequestMapping(value = "findAll",method = RequestMethod.GET) - @ApiOperation(value = "返回所有数据", notes = "返回所有数据",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Result findAll() { - List pages = service.findAll(); - if (pages == null || pages.size() == 0) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(pages); - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - /** - * 根据id查看模型 - * - * @param id id - * @return result - */ - @Override - public Result findById(@PathVariable Long id) { - return null; - } - - -// /** -// * 返回所有 带分页 -// * -// * @param start start -// * @param pageSize pageSize -// * @return 分页数据 -// */ -// @RequestMapping("findAll") -// public Result findAll(@RequestParam(value = "start", defaultValue = "1") int start, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) { -// Page pages = service.findAll(start, pageSize); -// if (pages == null || pages.getSize() <= 0) { -// return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); -// } -// return new Result(pages); -// } - - - /** - * 添加链接 - * - * @return model - */ - @RequestMapping(value = "add",method = RequestMethod.POST) - @ApiOperation(value = "添加链接", notes = "添加链接",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Result add(@RequestBody LinkModel model) { - LinkModel linkModel = service.findByName(model.getName()); - if (linkModel != null) { - return new Result(CodeConst.REPEAT.getResultCode(), CodeConst.REPEAT.getMessage()); - } - linkModel = new LinkModel(); - linkModel.setName(model.getName()); - linkModel.setUrl(model.getUrl()); - LinkModel addModel = service.add(linkModel); - return new Result(addModel); - } - - /** - * 更新链接 - * - * @return model - */ - @ApiOperation(value = "更新链接", notes = "更新链接",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "update",method = RequestMethod.POST) - public Result update(@RequestBody LinkModel model) { - LinkModel linkModel = service.findById(model.getId()); - if (linkModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - linkModel.setName(model.getName()); - linkModel.setUrl(model.getUrl()); - LinkModel updateModel = service.update(linkModel); - return new Result(updateModel); - } - - /** - * 删除链接 - * - * @param id id - * @return model - */ - @RequestMapping(value = "delete/{id}",method = RequestMethod.GET) - @ApiOperation(value = "删除链接", notes = "删除链接",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path") - }) - public Result delete(@PathVariable("id") Long id) { - LinkModel LinkModel = service.findById(id); - if (LinkModel == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - LinkModel delModel = service.delete(id); - return new Result(delModel); - } -} diff --git a/api/src/main/java/info/xiaomo/api/controller/TechnologyController.java b/api/src/main/java/info/xiaomo/api/controller/TechnologyController.java deleted file mode 100644 index 64e96e17..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/TechnologyController.java +++ /dev/null @@ -1,188 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.TechnologyModel; -import info.xiaomo.api.service.TechnologyService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:36 - * Description: 用户实体类 - * Copyright(©) 2015 by xiaomo. - **/ - - -@RestController -@RequestMapping("/technology") -@Api(value = "技术中心相关api",description = "技术中心相关api") -public class TechnologyController extends BaseController { - private final TechnologyService service; - - @Autowired - public TechnologyController(TechnologyService service) { - this.service = service; - } - - - @ApiOperation(value = "根据id查找技术", notes = "根据id查找技术",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/findById/{id}",method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一Id", required = true, dataType = "Long", paramType = "path") - }) - public Result findById(@PathVariable Long id) { - TechnologyModel model = service.findById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - @ApiOperation(value = "根据名字查找技术", notes = "根据名字查找技术",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/findByName/{name}",method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "技术名字", required = true, dataType = "name", paramType = "path") - }) - public Result findByName(@PathVariable String name) { - TechnologyModel model = service.findByName(name); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - @ApiOperation(value = "查找所有", notes = "查找所有",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/findAll",method = RequestMethod.GET) - public Result findAll() { - List all = service.findAll(); - if (all == null || all.isEmpty()) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(all); - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - - @ApiOperation(value = "添加链接", notes = "添加链接",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/add", method = RequestMethod.POST) - public Result add(@RequestBody TechnologyModel model) { - TechnologyModel addModel = service.findByName(model.getName()); - if (addModel != null) { - return new Result(CodeConst.REPEAT.getResultCode(), CodeConst.REPEAT.getMessage()); - } - addModel = service.add(model); - return new Result(addModel); - } - - @ApiOperation(value = "更新链接", notes = "更新链接",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/update", method = RequestMethod.POST) - public Result update(@RequestBody TechnologyModel model) { - TechnologyModel update = service.findById(model.getId()); - if (update == null) { - return new Result(CodeConst.CodeOR.getResultCode(), CodeConst.CodeOR.getMessage()); - } - update = service.update(model); - return new Result(update); - } - - - @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET) - @ApiOperation(value = "删除链接", notes = "删除链接",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path") - }) - public Result delete(@PathVariable Long id) { - TechnologyModel model = service.findById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - service.del(id); - return new Result(model); - } - -} diff --git a/api/src/main/java/info/xiaomo/api/controller/UserController.java b/api/src/main/java/info/xiaomo/api/controller/UserController.java deleted file mode 100644 index 4e3c2aca..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/UserController.java +++ /dev/null @@ -1,349 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.UserModel; -import info.xiaomo.api.service.UserService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.constant.GenderConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import info.xiaomo.core.exception.UserNotFoundException; -import info.xiaomo.core.untils.MD5Util; -import info.xiaomo.core.untils.MailUtil; -import info.xiaomo.core.untils.RandomUtil; -import info.xiaomo.core.untils.TimeUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.hibernate.service.spi.ServiceException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.text.ParseException; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月1日 17:51 - * Description: 用户控制器 - * Copyright(©) 2015 by xiaomo. - **/ -@RestController -@RequestMapping("/user") -@Api(value = "用户相关api", description = "用户相关api") -public class UserController extends BaseController { - - private final UserService service; - - @Autowired - public UserController(UserService service) { - this.service = service; - } - - /** - * 根据id 查找用户 - * - * @param id id - * @return result - */ - @ApiOperation(value = "查找用户", notes = "查找用户", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "findById/{id}", method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"), - }) - public Result findUserById(@PathVariable("id") Long id) { - UserModel userModel = service.findUserById(id); - if (userModel == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - return new Result(userModel); - } - - /** - * 添加用户 - */ - @ApiOperation(value = "添加用户", notes = "添加用户", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "addUser", method = RequestMethod.POST) - public Result addUser(@RequestBody UserModel user) { - UserModel userModel = service.findUserByEmail(user.getEmail()); - if (userModel != null) { - return new Result(CodeConst.USER_REPEAT.getResultCode(), CodeConst.USER_REPEAT.getMessage()); - } - String salt = RandomUtil.createSalt(); - user.setPassword(MD5Util.encode(user.getPassword(), salt)); - user.setValidateCode(MD5Util.encode(user.getEmail(), "")); - user.setSalt(salt); - service.addUser(user); - return new Result(user); - } - - /** - * 注册 - * - * @return result - */ - @ApiOperation(value = "注册", notes = "注册用户并发送验证链接到邮箱", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "用户名", required = true, dataType = "String", paramType = "path"), - @ApiImplicitParam(name = "密码", required = true, dataType = "String", paramType = "path") - }) - @RequestMapping(value = "register/{email}/{password}", method = RequestMethod.POST) - public Result register(@PathVariable("email") String email, @PathVariable("password") String password) throws Exception { - UserModel userModel = service.findUserByEmail(email); - //邮箱被占用 - if (userModel != null) { - return new Result(CodeConst.USER_REPEAT.getResultCode(), CodeConst.USER_REPEAT.getMessage()); - } - String redirectValidateUrl = MailUtil.redirectValidateUrl(email, password); - MailUtil.send(email, "帐号激活邮件", redirectValidateUrl); - return new Result(redirectValidateUrl); - } - - - /** - * 登录 - * - * @return result - */ - @ApiOperation(value = "登录", notes = "登录", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "email", value = "邮箱", required = true, dataType = "String", paramType = "path"), - @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String", paramType = "path") - }) - @RequestMapping(value = "login/{email}/{password}", method = RequestMethod.POST) - public Result login(@PathVariable("email") String email, @PathVariable("password") String password) { - UserModel userModel = service.findUserByEmail(email); - //找不到用户 - if (userModel == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - //密码不正确 - if (!MD5Util.encode(password, userModel.getSalt()).equals(userModel.getPassword())) { - return new Result(CodeConst.AUTH_FAILED.getResultCode(), CodeConst.AUTH_FAILED.getMessage()); - } - return new Result(userModel); - } - - - /** - * 修改密码 - * - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @ApiOperation(value = "修改密码", notes = "修改密码", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "changePassword", method = RequestMethod.POST) - public Result changePassword(@RequestBody UserModel user) throws UserNotFoundException { - UserModel userByEmail = service.findUserByEmail(user.getEmail()); - if (userByEmail == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - String salt = RandomUtil.createSalt(); - userByEmail.setPassword(MD5Util.encode(user.getPassword(), salt)); - userByEmail.setNickName(user.getNickName()); - userByEmail.setSalt(salt); - UserModel updateUser = service.updateUser(userByEmail); - return new Result(updateUser); - } - - /** - * 更新用户信息 - * - * @return model - * @throws UserNotFoundException UserNotFoundException - */ - @ApiOperation(value = "更新用户信息", notes = "更新用户信息", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "update", method = RequestMethod.POST) - public Result update(@RequestBody UserModel user) throws UserNotFoundException { - UserModel userModel = service.findUserByEmail(user.getEmail()); - if (userModel == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - userModel = new UserModel(); - userModel.setEmail(user.getEmail()); - userModel.setNickName(user.getNickName()); - userModel.setPhone(user.getPhone()); - userModel.setAddress(user.getAddress()); - userModel.setGender(user.getGender()); - userModel.setValidateCode(MD5Util.encode(user.getEmail(), "")); - UserModel updateUser = service.updateUser(userModel); - return new Result(updateUser); - } - - /** - * 返回所有用户数据 - * - * @return result - */ - @ApiOperation(value = "返回所有用户数据", notes = "返回所有用户数据", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "findAll", method = RequestMethod.GET) - public Result getAll() { - List pages = service.findAll(); - if (pages == null || pages.size() <= 0) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(pages); - } - - - /** - * 根据id删除用户 - * - * @param id id - * @return result - */ - @RequestMapping(value = "delete/{id}", method = RequestMethod.GET) - @ApiOperation(value = "根据id删除用户", notes = "根据id删除用户", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"), - }) - public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundException { - UserModel userModel = service.deleteUserById(id); - if (userModel == null) { - return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()); - } - return new Result(userModel); - } - - /** - * 处理激活 - */ - @ApiOperation(value = "处理激活", notes = "处理激活", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "validateEmail", method = RequestMethod.POST) - public Result validateEmail(@RequestBody UserModel user - ) throws ServiceException, ParseException, UserNotFoundException { - //数据访问层,通过email获取用户信息 - UserModel userModel = service.findUserByEmail(user.getEmail()); - if (userModel != null) { - return new Result(CodeConst.USER_REPEAT.getResultCode(), CodeConst.USER_REPEAT.getMessage()); - } - //验证码是否过期 - if (user.getRegisterTime() + TimeUtil.ONE_DAY_IN_MILLISECONDS * 2 < TimeUtil.getNowOfMills()) { - LOGGER.info("用户{}使用己过期的激活码{}激活邮箱失败!", user.getEmail(), user.getEmail()); - return new Result(CodeConst.TIME_PASSED.getResultCode(), CodeConst.TIME_PASSED.getMessage()); - } - //激活 - String salt = RandomUtil.createSalt(); - userModel = new UserModel(); - userModel.setNickName(user.getNickName()); - userModel.setEmail(user.getEmail()); - userModel.setGender(GenderConst.secret); - userModel.setValidateCode(MD5Util.encode(user.getEmail(), salt)); - userModel.setPhone(0L); - userModel.setSalt(salt); - userModel.setAddress(""); - userModel.setPassword(MD5Util.encode(user.getPassword(), salt)); - userModel = service.addUser(userModel); - LOGGER.info("用户{}使用激活码{}激活邮箱成功!", userModel.getEmail(), userModel.getValidateCode()); - return new Result(userModel); - } - - /** - * 查找所有(不带分页) - * - * @return result - */ - @Override - public Result findAll() { - return null; - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - /** - * 根据id查看模型 - * - * @param id id - * @return result - */ - @Override - public Result findById(@PathVariable Long id) { - return null; - } - - /** - * 根据名字查找模型 - * - * @param name name - * @return result - */ - @Override - public Result findByName(@PathVariable String name) { - return null; - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } -} diff --git a/api/src/main/java/info/xiaomo/api/controller/WebSetController.java b/api/src/main/java/info/xiaomo/api/controller/WebSetController.java deleted file mode 100644 index b8c7cfaf..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/WebSetController.java +++ /dev/null @@ -1,172 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.SystemSetModel; -import info.xiaomo.api.service.WebSetService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年5月6日 14:21 - * Description: 系统设置控制器 - * Copyright(©) 2015 by xiaomo. - **/ -@RestController -@RequestMapping("/webSet") -@Api(value = "网站设置相关api",description = "网站设置相关api") -public class WebSetController extends BaseController { - - private final WebSetService service; - - @Autowired - public WebSetController(WebSetService service) { - this.service = service; - } - - /** - * 查找所有 - * - * @return list - */ - @ApiOperation(value = "查找所有", notes = "查找所有",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "findAll", method = RequestMethod.GET) - public Result findAll() { - List list = service.findAll(); - if (list.isEmpty() || list.size() == 0) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(list); - - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - /** - * 根据id查看模型 - * - * @param id id - * @return result - */ - @Override - public Result findById(@PathVariable Long id) { - return null; - } - - /** - * 根据名字查找模型 - * - * @param name name - * @return result - */ - @Override - public Result findByName(@PathVariable String name) { - return null; - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - /** - * 更新 - * - * @return SystemSetModel - */ - @ApiOperation(value = "更新", notes = "更新",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "update", method = RequestMethod.POST) - public Result update(@RequestBody SystemSetModel systemSetModel) { - List all = service.findAll(); - if (all.size()> 1) { - return new Result(CodeConst.CodeOR.getResultCode(), CodeConst.CodeOR.getMessage()); - } - for (SystemSetModel setModel : all) { - setModel.setSiteName(systemSetModel.getSiteName()); - setModel.setIcon(systemSetModel.getIcon()); - setModel.setFromYear(systemSetModel.getFromYear()); - setModel.setToYear(systemSetModel.getToYear()); - setModel.setBeianUrl(systemSetModel.getBeianUrl()); - setModel.setBeianNumber(systemSetModel.getBeianNumber()); - SystemSetModel add = service.update(setModel); - return new Result(add); - } - return new Result(CodeConst.CodeOR.getResultCode(), CodeConst.CodeOR.getMessage()); - } -} diff --git a/api/src/main/java/info/xiaomo/api/controller/WorksController.java b/api/src/main/java/info/xiaomo/api/controller/WorksController.java deleted file mode 100644 index 3300ed3d..00000000 --- a/api/src/main/java/info/xiaomo/api/controller/WorksController.java +++ /dev/null @@ -1,189 +0,0 @@ -package info.xiaomo.api.controller; - -import info.xiaomo.api.model.WorksModel; -import info.xiaomo.api.service.WorksService; -import info.xiaomo.core.constant.CodeConst; -import info.xiaomo.core.base.BaseController; -import info.xiaomo.core.base.Result; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:36 - * Description: 用户实体类 - * Copyright(©) 2015 by xiaomo. - **/ - - -@RequestMapping("/works") -@RestController -@Api(value = "作品相关api",description = "作品相关api") -public class WorksController extends BaseController { - - private final WorksService service; - - @Autowired - public WorksController(WorksService service) { - this.service = service; - } - - - @RequestMapping(value = "/findById/{id}",method = RequestMethod.GET) - @ApiOperation(value = "根据id查找作品", notes = "根据id查找作品",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"), - }) - public Result findById(@PathVariable Long id) { - WorksModel model = service.findById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - @RequestMapping(value = "/findAll",method = RequestMethod.GET) - @ApiOperation(value = "查找所有", notes = "查找所有",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - public Result findAll() { - List all = service.findAll(); - if (all == null || all.isEmpty()) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(all); - } - - /** - * 带分页 - * - * @param start 起始页 - * @param pageSize 页码数 - * @return result - */ - @Override - public Result findAll(@PathVariable int start, @PathVariable int pageSize) { - return null; - } - - - @RequestMapping(value = "/findByName/{name}",method = RequestMethod.GET) - @ApiOperation(value = "根据名字查找作品", notes = "根据名字查找作品",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "作品名字", required = true, dataType = "String", paramType = "path"), - }) - public Result findByName(@PathVariable String name) { - WorksModel model = service.findByName(name); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - return new Result(model); - } - - /** - * 根据名字删除模型 - * - * @param name name - * @return result - */ - @Override - public Result delByName(@PathVariable String name) { - return null; - } - - /** - * 根据id删除模型 - * - * @param id id - * @return result - */ - @Override - public Result delById(@PathVariable Long id) { - return null; - } - - /** - * 添加模型 - * - * @param model model - * @return result - */ - @Override - public Result add(@RequestBody Object model) { - return null; - } - - /** - * 更新 - * - * @param model model - * @return result - */ - @Override - public Result update(@RequestBody Object model) { - return null; - } - - /** - * 批量删除 - * - * @param ids ids - * @return result - */ - @Override - public Result delByIds(@PathVariable List ids) { - return null; - } - - @ApiOperation(value = "添加作品", notes = "添加作品",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/add", method = RequestMethod.POST) - public Result add(@RequestBody WorksModel model) { - WorksModel addModel = service.findByName(model.getName()); - if (addModel != null) { - return new Result(CodeConst.REPEAT.getResultCode(), CodeConst.REPEAT.getMessage()); - } - addModel = service.add(model); - return new Result(addModel); - } - - @ApiOperation(value = "更新作品", notes = "更新作品",httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/update", method = RequestMethod.POST) - public Result update(@RequestBody WorksModel model) { - WorksModel worksModel = service.findById(model.getId()); - if (worksModel == null) { - return new Result(CodeConst.CodeOR.getResultCode(), CodeConst.CodeOR.getMessage()); - } - worksModel = service.update(worksModel); - return new Result(worksModel); - } - - - @ApiOperation(value = "根据id删除作品", notes = "根据id删除作品",httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) - @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET) - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"), - }) - public Result delete(@PathVariable Long id) { - WorksModel model = service.findById(id); - if (model == null) { - return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage()); - } - service.del(id); - return new Result(model); - } - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/AdminUserDao.java b/api/src/main/java/info/xiaomo/api/dao/AdminUserDao.java deleted file mode 100644 index 29fa2f76..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/AdminUserDao.java +++ /dev/null @@ -1,33 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.AdminModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 13:08 - * Copyright(©) 2015 by xiaomo. - */ -@Repository -public interface AdminUserDao extends JpaRepository { - - AdminModel findAdminUserByUserName(String s); - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/ChangeLogDao.java b/api/src/main/java/info/xiaomo/api/dao/ChangeLogDao.java deleted file mode 100644 index 6523252f..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/ChangeLogDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.ChangeLogModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:52 - * Copyright(©) 2015 by xiaomo. - **/ -@Repository -public interface ChangeLogDao extends JpaRepository { - - ChangeLogModel findByName(String name); - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/LinkDao.java b/api/src/main/java/info/xiaomo/api/dao/LinkDao.java deleted file mode 100644 index f66e74cf..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/LinkDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.LinkModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:52 - * Copyright(©) 2015 by xiaomo. - **/ -@Repository -public interface LinkDao extends JpaRepository { - - LinkModel findLinkByName(String name); - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/TechnologyDao.java b/api/src/main/java/info/xiaomo/api/dao/TechnologyDao.java deleted file mode 100644 index a9c23f69..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/TechnologyDao.java +++ /dev/null @@ -1,34 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.TechnologyModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 13:08 - * Copyright(©) 2015 by xiaomo. - */ -@Repository -public interface TechnologyDao extends JpaRepository { - - TechnologyModel findTechnologyByName(String name); - - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/UserDao.java b/api/src/main/java/info/xiaomo/api/dao/UserDao.java deleted file mode 100644 index 17ad1ae5..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/UserDao.java +++ /dev/null @@ -1,33 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.UserModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/3 10:53 - * Copyright(©) 2015 by xiaomo. - */ - -@Repository -public interface UserDao extends JpaRepository { - - UserModel findUserByEmail(String email); -} diff --git a/api/src/main/java/info/xiaomo/api/dao/WebSetDao.java b/api/src/main/java/info/xiaomo/api/dao/WebSetDao.java deleted file mode 100644 index fae4e534..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/WebSetDao.java +++ /dev/null @@ -1,23 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.SystemSetModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年5月6日 14:26 - * Copyright(©) 2015 by xiaomo. - **/ -@Repository -public interface WebSetDao extends JpaRepository { - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/WorksDao.java b/api/src/main/java/info/xiaomo/api/dao/WorksDao.java deleted file mode 100644 index e3b06ce7..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/WorksDao.java +++ /dev/null @@ -1,33 +0,0 @@ -package info.xiaomo.api.dao; - -import info.xiaomo.api.model.WorksModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 13:08 - * Copyright(©) 2015 by xiaomo. - */ -@Repository -public interface WorksDao extends JpaRepository { - - WorksModel findWorkByName(String name); - -} diff --git a/api/src/main/java/info/xiaomo/api/dao/base/CommonDao.java b/api/src/main/java/info/xiaomo/api/dao/base/CommonDao.java deleted file mode 100644 index 142236ab..00000000 --- a/api/src/main/java/info/xiaomo/api/dao/base/CommonDao.java +++ /dev/null @@ -1,55 +0,0 @@ -package info.xiaomo.api.dao.base; - -import info.xiaomo.core.base.BaseModel; -import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.Query; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月1日 20:46 - * Description: 公共dao层 - * Copyright(©) 2015 by xiaomo. - **/ -@Repository -@Transactional -public class CommonDao { - - @PersistenceContext - private EntityManager entityManager; - - public T get(Class type, long id) { - return entityManager.find(type, id); - } - - public T update(T entity) { - return entityManager.merge(entity); - } - - public void save(T entity) { - entityManager.persist(entity); - } - - public void delete(T entity) { - entityManager.remove(entity); - } - - public List getAll(Class tableClass) { - Query query = entityManager.createQuery("from " + tableClass.getSimpleName()); - return query.getResultList(); - } - - -} \ No newline at end of file diff --git a/api/src/main/java/info/xiaomo/api/model/ChangeLogModel.java b/api/src/main/java/info/xiaomo/api/model/ChangeLogModel.java deleted file mode 100644 index d029c17d..00000000 --- a/api/src/main/java/info/xiaomo/api/model/ChangeLogModel.java +++ /dev/null @@ -1,49 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import java.io.Serializable; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/517:17 - * Copyright(©) 2015 by xiaomo. - **/ -@Entity -@Table(name = "changeLog") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "更新日志实体类") -public class ChangeLogModel extends BaseModel implements Serializable { - - @ApiModelProperty(value = "更新日志描述", required = true) - @Column(name = "Name") - private String name; - - @ApiModelProperty(value = "上线时间(字符串自己编辑)", required = true) - @Column(name = "OnlineTime") - private String onlineTime; -} diff --git a/api/src/main/java/info/xiaomo/api/model/LinkModel.java b/api/src/main/java/info/xiaomo/api/model/LinkModel.java deleted file mode 100644 index d2d87e0a..00000000 --- a/api/src/main/java/info/xiaomo/api/model/LinkModel.java +++ /dev/null @@ -1,49 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import java.io.Serializable; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:47 - * Copyright(©) 2015 by xiaomo. - **/ -@Entity -@Table(name = "link") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "友情链接实体类") -public class LinkModel extends BaseModel implements Serializable { - - @ApiModelProperty(value = "友情链接的名字", required = true) - @Column(name = "Name") - private String name; - - @ApiModelProperty(value = "友情链接的URL", required = true) - @Column(name = "Url") - private String url; -} diff --git a/api/src/main/java/info/xiaomo/api/model/SystemSetModel.java b/api/src/main/java/info/xiaomo/api/model/SystemSetModel.java deleted file mode 100644 index 21962301..00000000 --- a/api/src/main/java/info/xiaomo/api/model/SystemSetModel.java +++ /dev/null @@ -1,67 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import java.io.Serializable; -import java.util.Calendar; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/517:17 - * Copyright(©) 2015 by xiaomo. - **/ -@Entity -@Table(name = "systemSet") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "系统设置实体类") -public class SystemSetModel extends BaseModel implements Serializable { - - @ApiModelProperty(value = "站点名字", required = false) - @Column(name = "SiteName") - private String siteName = "小莫-fighting"; - - @ApiModelProperty(value = "站点图标") - @Column(name = "Icon") - private String icon = ""; - - @ApiModelProperty(value = "footer的开始年份") - @Column(name = "FromYear") - private int fromYear = Calendar.getInstance().get(Calendar.YEAR); - - @ApiModelProperty(value = "footer的结束年份") - @Column(name = "ToYear") - private int toYear = Calendar.getInstance().get(Calendar.YEAR); - - @ApiModelProperty(value = "备案号") - @Column(name = "BeianNumber") - private String beianNumber = "浙ICP备15009606号"; - - @ApiModelProperty(value = "备案地址") - @Column(name = "BeianUrl") - private String beianUrl = "http://www.miitbeian.gov.cn/"; - -} diff --git a/api/src/main/java/info/xiaomo/api/model/TechnologyModel.java b/api/src/main/java/info/xiaomo/api/model/TechnologyModel.java deleted file mode 100644 index 5774c195..00000000 --- a/api/src/main/java/info/xiaomo/api/model/TechnologyModel.java +++ /dev/null @@ -1,58 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:27 - * Copyright(©) 2015 by xiaomo. - **/ - -@Entity -@Table(name = "technology") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "技术中心实体类") -public class TechnologyModel extends BaseModel { - - @ApiModelProperty(value = "技术名字") - @Column(name = "Name") - private String name; - - @ApiModelProperty(value = "url") - @Column(name = "Url") - private String url; - - @ApiModelProperty(value = "简介") - @Column(name = "Summary") - private String summary; - - @ApiModelProperty(value = "图片链接") - @Column(name = "ImgUrl") - private String imgUrl; - -} diff --git a/api/src/main/java/info/xiaomo/api/model/UserModel.java b/api/src/main/java/info/xiaomo/api/model/UserModel.java deleted file mode 100644 index b7079a56..00000000 --- a/api/src/main/java/info/xiaomo/api/model/UserModel.java +++ /dev/null @@ -1,81 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import java.io.Serializable; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月1日 17:36 - * Copyright(©) 2015 by xiaomo. - **/ -@Entity -@Table(name = "user") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "用户实体类") -public class UserModel extends BaseModel implements Serializable { - - @ApiModelProperty(value = "登录用户") - @Column(name = "Email") - private String email; - - @ApiModelProperty(value = "昵称") - @Column(name = "NickName") - private String nickName; - - @ApiModelProperty(value = "密码") - @Column(name = "Password") - private String password; - - @ApiModelProperty(value = "盐值") - @Column(name = "Salt") - private String salt; - - @ApiModelProperty(value = "激活码") - @Column(name = "ValidateCode") - private String validateCode; - - @ApiModelProperty(value = "性别:1男2女0保密") - @Column(name = "Gender") - private int gender = 0; - - @ApiModelProperty(value = "电话") - @Column(name = "Phone") - private Long phone = 0L; - - @ApiModelProperty(value = "图片地址") - @Column(name = "ImgUrl") - private String imgUrl = ""; - - @ApiModelProperty(value = "地址") - @Column(name = "Address") - private String address = ""; - - @ApiModelProperty(value = "注册时间(时间戳)") - @Column(name = "RegisterTime") - private Long RegisterTime = 0L; -} diff --git a/api/src/main/java/info/xiaomo/api/model/WorksModel.java b/api/src/main/java/info/xiaomo/api/model/WorksModel.java deleted file mode 100644 index 080750a1..00000000 --- a/api/src/main/java/info/xiaomo/api/model/WorksModel.java +++ /dev/null @@ -1,62 +0,0 @@ -package info.xiaomo.api.model; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import info.xiaomo.core.base.BaseModel; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.*; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:15 - * Copyright(©) 2015 by xiaomo. - **/ - -// hibernate -@Entity -@Table(name = "works") -// lomlok -@Data -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -// fast jackson -@JsonInclude(JsonInclude.Include.NON_EMPTY) -// swagger ui -@ApiModel(value = "作品实体类") -public class WorksModel extends BaseModel { - - @ApiModelProperty(value = "作品") - @Column(name = "Name") - private String name; - - @ApiModelProperty(value = "url") - @Column(name = "Url") - private String url; - - @ApiModelProperty(value = "简介") - @Column(name = "Summary") - private String summary; - - @ApiModelProperty(value = "完成时间(字符串自己编辑)") - @Column(name = "CompleteTime") - private String completeTime; - - @ApiModelProperty(value = "图片链接") - @Column(name = "ImgUrl") - private String imgUrl; -} diff --git a/api/src/main/java/info/xiaomo/api/service/AdminUserService.java b/api/src/main/java/info/xiaomo/api/service/AdminUserService.java deleted file mode 100644 index feb8aab5..00000000 --- a/api/src/main/java/info/xiaomo/api/service/AdminUserService.java +++ /dev/null @@ -1,48 +0,0 @@ -package info.xiaomo.api.service; - -import info.xiaomo.api.model.AdminModel; -import info.xiaomo.core.exception.UserNotFoundException; -import org.springframework.data.domain.Page; - -import java.util.List; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 13:04 - * Copyright(©) 2015 by xiaomo. - */ -public interface AdminUserService { - - AdminModel findAdminUserByUserName(String userName); - - AdminModel findAdminUserById(Long id); - - AdminModel addAdminUser(AdminModel model); - - AdminModel updateAdminUser(AdminModel model) throws UserNotFoundException; - - Page getAdminUsers(int start, int pageSize); - - List getAdminUsers(); - - AdminModel deleteAdminUserById(Long id) throws UserNotFoundException; - - AdminModel forbidAdminUserById(Long id) throws UserNotFoundException; - -} diff --git a/api/src/main/java/info/xiaomo/api/service/ChangeLogService.java b/api/src/main/java/info/xiaomo/api/service/ChangeLogService.java deleted file mode 100644 index 9881646c..00000000 --- a/api/src/main/java/info/xiaomo/api/service/ChangeLogService.java +++ /dev/null @@ -1,36 +0,0 @@ -package info.xiaomo.api.service; - -import info.xiaomo.api.model.ChangeLogModel; -import org.springframework.data.domain.Page; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:49 - * Copyright(©) 2015 by xiaomo. - **/ -public interface ChangeLogService { - - ChangeLogModel findById(Long id); - - ChangeLogModel findByName(String name); - - Page findAll(int start, int pageSize); - - List findAll(); - - ChangeLogModel add(ChangeLogModel model); - - ChangeLogModel update(ChangeLogModel model); - - ChangeLogModel delete(Long id); -} diff --git a/api/src/main/java/info/xiaomo/api/service/LinkService.java b/api/src/main/java/info/xiaomo/api/service/LinkService.java deleted file mode 100644 index a506d672..00000000 --- a/api/src/main/java/info/xiaomo/api/service/LinkService.java +++ /dev/null @@ -1,38 +0,0 @@ -package info.xiaomo.api.service; - - -import info.xiaomo.api.model.LinkModel; -import org.springframework.data.domain.Page; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016/4/1119:49 - * Copyright(©) 2015 by xiaomo. - **/ -public interface LinkService { - - LinkModel findById(Long id); - - LinkModel findByName(String name); - - Page findAll(int start, int pageSize); - - List findAll(); - - LinkModel add(LinkModel model); - - LinkModel update(LinkModel model); - - LinkModel delete(Long id); - -} diff --git a/api/src/main/java/info/xiaomo/api/service/TechnologyService.java b/api/src/main/java/info/xiaomo/api/service/TechnologyService.java deleted file mode 100644 index 751dbd38..00000000 --- a/api/src/main/java/info/xiaomo/api/service/TechnologyService.java +++ /dev/null @@ -1,39 +0,0 @@ -package info.xiaomo.api.service; - - -import info.xiaomo.api.model.TechnologyModel; -import org.springframework.data.domain.Page; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:33 - * Copyright(©) 2015 by xiaomo. - **/ - -public interface TechnologyService { - - List findAll(); - - Page findAll(int start, int pageSize); - - TechnologyModel findById(Long id); - - TechnologyModel findByName(String name); - - TechnologyModel update(TechnologyModel model); - - TechnologyModel add(TechnologyModel model); - - void del(Long id); - -} diff --git a/api/src/main/java/info/xiaomo/api/service/UserService.java b/api/src/main/java/info/xiaomo/api/service/UserService.java deleted file mode 100644 index a708c346..00000000 --- a/api/src/main/java/info/xiaomo/api/service/UserService.java +++ /dev/null @@ -1,43 +0,0 @@ -package info.xiaomo.api.service; - - -import info.xiaomo.api.model.UserModel; -import info.xiaomo.core.exception.UserNotFoundException; -import org.springframework.data.domain.Page; -import org.springframework.transaction.annotation.Isolation; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月1日 17:45 - * Copyright(©) 2015 by xiaomo. - **/ -public interface UserService { - - UserModel findUserById(Long id); - - @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED) - UserModel findUserByEmail(String email); - - UserModel addUser(UserModel model); - - UserModel updateUser(UserModel model) throws UserNotFoundException; - - Page findAll(int start, int pageSize); - - List findAll(); - - UserModel deleteUserById(Long id) throws UserNotFoundException; - -} diff --git a/api/src/main/java/info/xiaomo/api/service/WebSetService.java b/api/src/main/java/info/xiaomo/api/service/WebSetService.java deleted file mode 100644 index 5635b8e5..00000000 --- a/api/src/main/java/info/xiaomo/api/service/WebSetService.java +++ /dev/null @@ -1,30 +0,0 @@ -package info.xiaomo.api.service; - - -import info.xiaomo.api.model.SystemSetModel; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年5月6日 14:23 - * Copyright(©) 2015 by xiaomo. - **/ -public interface WebSetService { - - List findAll(); - - SystemSetModel findById(Long id); - - SystemSetModel update(SystemSetModel model); - - SystemSetModel add(SystemSetModel model); -} diff --git a/api/src/main/java/info/xiaomo/api/service/WorksService.java b/api/src/main/java/info/xiaomo/api/service/WorksService.java deleted file mode 100644 index 0f74fd11..00000000 --- a/api/src/main/java/info/xiaomo/api/service/WorksService.java +++ /dev/null @@ -1,38 +0,0 @@ -package info.xiaomo.api.service; - - -import info.xiaomo.api.model.WorksModel; -import org.springframework.data.domain.Page; - -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:33 - * Copyright(©) 2015 by xiaomo. - **/ - -public interface WorksService { - - List findAll(); - - Page findAll(int start, int pageSize); - - WorksModel findById(Long id); - - WorksModel findByName(String name); - - WorksModel update(WorksModel model); - - WorksModel add(WorksModel model); - - void del(Long id); -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/AdminUserServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/AdminUserServiceImpl.java deleted file mode 100644 index 86a6b25f..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/AdminUserServiceImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.AdminUserDao; -import info.xiaomo.api.model.AdminModel; -import info.xiaomo.api.service.AdminUserService; -import info.xiaomo.core.exception.UserNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * │\__╭╭╭╭╭__/│ - * │ │ - * │ │ - * │ - -│ - * │≡ o ≡ │ - * │ │ - * ╰——┬O◤▽◥O┬——╯ - * | o | - * |╭---╮把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 16/4/2 13:34 - * Description: 后台用户serviceImpl - * Copyright(©) 2015 by xiaomo. - */ -@Service -public class AdminUserServiceImpl implements AdminUserService { - - private final AdminUserDao dao; - - @Autowired - public AdminUserServiceImpl(AdminUserDao dao) { - this.dao = dao; - } - - @Override - public AdminModel findAdminUserByUserName(String userName) { - return dao.findAdminUserByUserName(userName); - } - - @Override - public AdminModel findAdminUserById(Long id) { - return dao.findOne(id); - } - - @Override - public AdminModel addAdminUser(AdminModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - - } - - @Override - public AdminModel updateAdminUser(AdminModel model) throws UserNotFoundException { - AdminModel userUpdate = dao.findOne(model.getId()); - if (userUpdate == null) { - throw new UserNotFoundException(); - } - if (model.getPassword() != null) { - userUpdate.setPassword(model.getPassword()); - } - if (model.getUserName() != null) { - userUpdate.setUserName(model.getUserName()); - } - userUpdate.setUpdateTime(new Date()); - return dao.save(userUpdate); - } - - @Override - public Page getAdminUsers(int start, int pageSize) { - Sort sort = new Sort(Sort.Direction.DESC, "createTime"); - return dao.findAll(new PageRequest(start - 1, pageSize, sort)); - } - - @Override - public AdminModel deleteAdminUserById(Long id) throws UserNotFoundException { - AdminModel adminModel = dao.findOne(id); - if (adminModel == null) { - throw new UserNotFoundException(); - } - dao.delete(adminModel.getId()); - return adminModel; - } - - @Override - public AdminModel forbidAdminUserById(Long id) throws UserNotFoundException { - AdminModel model = dao.findOne(id); - if (model == null) { - throw new UserNotFoundException(); - } - model.setStatus(2); - return dao.save(model); - } - - @Override - public List getAdminUsers() { - return dao.findAll(); - } -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/ChangeLogServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/ChangeLogServiceImpl.java deleted file mode 100644 index 203ef54d..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/ChangeLogServiceImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.ChangeLogDao; -import info.xiaomo.api.model.ChangeLogModel; -import info.xiaomo.api.service.ChangeLogService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月11日 19:49 - * Copyright(©) 2015 by xiaomo. - **/ -@Service -public class ChangeLogServiceImpl implements ChangeLogService { - - private final ChangeLogDao dao; - - @Autowired - public ChangeLogServiceImpl(ChangeLogDao dao) { - this.dao = dao; - } - - @Override - public ChangeLogModel findById(Long id) { - return dao.findOne(id); - } - - @Override - public ChangeLogModel findByName(String name) { - return dao.findByName(name); - } - - @Override - public Page findAll(int start, int pageSize) { - Sort sort = new Sort(Sort.Direction.DESC, "createTime"); - return dao.findAll(new PageRequest(start - 1, pageSize, sort)); - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public ChangeLogModel add(ChangeLogModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - } - - @Override - public ChangeLogModel update(ChangeLogModel model) { - ChangeLogModel updateModel = dao.findOne(model.getId()); - if (model.getName() != null) { - updateModel.setName(model.getName()); - } - updateModel.setUpdateTime(new Date()); - return dao.save(updateModel); - } - - @Override - public ChangeLogModel delete(Long id) { - ChangeLogModel model = dao.findOne(id); - if (model != null) { - dao.delete(id); - } - return model; - } -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/LinkServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/LinkServiceImpl.java deleted file mode 100644 index 65dd1e4b..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/LinkServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.LinkDao; -import info.xiaomo.api.model.LinkModel; -import info.xiaomo.api.service.LinkService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月11日 19:50 - * Copyright(©) 2015 by xiaomo. - **/ -@Service -public class LinkServiceImpl implements LinkService { - - private final LinkDao dao; - - @Autowired - public LinkServiceImpl(LinkDao dao) { - this.dao = dao; - } - - @Override - public LinkModel findById(Long id) { - return dao.findOne(id); - } - - @Override - public LinkModel findByName(String name) { - return dao.findLinkByName(name); - } - - @Override - public Page findAll(int start, int pageSize) { - Sort sort = new Sort(Sort.Direction.DESC, "order"); - return dao.findAll(new PageRequest(start - 1, pageSize, sort)); - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public LinkModel add(LinkModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - } - - @Override - public LinkModel update(LinkModel model) { - LinkModel updateModel = dao.findOne(model.getId()); - if (model.getName() != null) { - updateModel.setName(model.getName()); - } - if (model.getUrl() != null) { - updateModel.setUrl(model.getUrl()); - } - model.setUpdateTime(new Date()); - return dao.save(updateModel); - } - - @Override - public LinkModel delete(Long id) { - LinkModel model = dao.findOne(id); - if (model != null) { - dao.delete(id); - } - return model; - } -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/TechnologyServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/TechnologyServiceImpl.java deleted file mode 100644 index bf000171..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/TechnologyServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.TechnologyDao; -import info.xiaomo.api.model.TechnologyModel; -import info.xiaomo.api.service.TechnologyService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:34 - * Copyright(©) 2015 by xiaomo. - **/ - -@Service -public class TechnologyServiceImpl implements TechnologyService { - - private TechnologyDao dao; - - @Autowired - public TechnologyServiceImpl(TechnologyDao dao) { - this.dao = dao; - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public Page findAll(int start, int pageSize) { - return dao.findAll(new PageRequest(start - 1, pageSize)); - } - - @Override - public TechnologyModel findById(Long id) { - return dao.findOne(id); - } - - @Override - public TechnologyModel findByName(String name) { - return dao.findTechnologyByName(name); - } - - @Override - public TechnologyModel update(TechnologyModel model) { - TechnologyModel result = dao.findOne(model.getId()); - if ("".equals(model.getUrl()) && model.getUrl() != null) { - result.setUrl(model.getUrl()); - } - if ("".equals(model.getName()) && model.getName() != null) { - result.setName(model.getName()); - } - - if ("".equals(model.getSummary()) && model.getSummary() != null) { - result.setSummary(model.getSummary()); - } - if ("".equals(model.getImgUrl()) && model.getImgUrl() != null) { - result.setImgUrl(model.getImgUrl()); - } - result.setUpdateTime(new Date()); - return dao.save(result); - } - - @Override - public TechnologyModel add(TechnologyModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - } - - @Override - public void del(Long id) { - dao.delete(id); - } -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/UserServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/UserServiceImpl.java deleted file mode 100644 index ec4c6d37..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/UserServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.UserDao; -import info.xiaomo.api.model.UserModel; -import info.xiaomo.api.service.UserService; -import info.xiaomo.core.exception.UserNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年4月1日 17:46 - * Description: 用户service实现 - * Copyright(©) 2015 by xiaomo. - **/ -@Service -public class UserServiceImpl implements UserService { - - private final UserDao dao; - - @Autowired - public UserServiceImpl(UserDao dao) { - this.dao = dao; - } - - @Override - public UserModel findUserById(Long id) { - return dao.findOne(id); - } - - @Override - public UserModel findUserByEmail(String email) { - return dao.findUserByEmail(email); - } - - @Override - public UserModel addUser(UserModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - } - - @Override - public UserModel updateUser(UserModel model) throws UserNotFoundException { - UserModel userUpdate = dao.findUserByEmail(model.getEmail()); - if (userUpdate == null) { - throw new UserNotFoundException(); - } - if (model.getAddress() != null) { - userUpdate.setAddress(model.getAddress()); - } - if (model.getEmail() != null) { - userUpdate.setEmail(model.getEmail()); - } - if (model.getGender() != 0) { - userUpdate.setGender(model.getGender()); - } - if (model.getImgUrl() != null) { - userUpdate.setImgUrl(model.getImgUrl()); - } - if (model.getNickName() != null) { - userUpdate.setNickName(model.getNickName()); - } - if (model.getPhone() != 0) { - userUpdate.setPhone(model.getPhone()); - } - userUpdate.setUpdateTime(new Date()); - dao.save(userUpdate); - return userUpdate; - } - - @Override - public Page findAll(int start, int pageSize) { - Sort sort = new Sort(Sort.Direction.DESC, "createTime"); - return dao.findAll(new PageRequest(start - 1, pageSize, sort)); - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public UserModel deleteUserById(Long id) throws UserNotFoundException { - UserModel userModel = dao.findOne(id); - if (userModel == null) { - throw new UserNotFoundException(); - } - dao.delete(userModel.getId()); - return userModel; - } - -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/WebSetServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/WebSetServiceImpl.java deleted file mode 100644 index 748ff290..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/WebSetServiceImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.WebSetDao; -import info.xiaomo.api.model.SystemSetModel; -import info.xiaomo.api.service.WebSetService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年5月6日 14:24 - * Copyright(©) 2015 by xiaomo. - **/ -@Service -public class WebSetServiceImpl implements WebSetService { - - private final WebSetDao dao; - - @Autowired - public WebSetServiceImpl(WebSetDao dao) { - this.dao = dao; - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public SystemSetModel findById(Long id) { - return dao.findOne(id); - } - - @Override - public SystemSetModel update(SystemSetModel model) { - SystemSetModel one = dao.findOne(model.getId()); - if (one == null) { - return null; - } - if (model.getBeianNumber() != null) { - one.setBeianNumber(model.getBeianNumber()); - } - if (model.getBeianUrl() != null) { - one.setBeianUrl(model.getBeianUrl()); - } - if (model.getFromYear() != 0) { - one.setFromYear(model.getFromYear()); - } - if (model.getToYear() != 0) { - one.setToYear(model.getToYear()); - } - if (model.getIcon() != null) { - one.setIcon(model.getIcon()); - } - if (model.getSiteName() != null) { - one.setSiteName(model.getSiteName()); - } - one.setUpdateTime(new Date()); - dao.save(one); - return one; - - } - - @Override - public SystemSetModel add(SystemSetModel model) { - dao.save(model); - return model; - } -} diff --git a/api/src/main/java/info/xiaomo/api/service/impl/WorksServiceImpl.java b/api/src/main/java/info/xiaomo/api/service/impl/WorksServiceImpl.java deleted file mode 100644 index daa5412d..00000000 --- a/api/src/main/java/info/xiaomo/api/service/impl/WorksServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -package info.xiaomo.api.service.impl; - -import info.xiaomo.api.dao.WorksDao; -import info.xiaomo.api.model.WorksModel; -import info.xiaomo.api.service.WorksService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - * 把今天最好的表现当作明天最新的起点..〜 - * いま 最高の表現 として 明日最新の始発..〜 - * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. - * - * author: xiaomo - * github: https://github.com/xiaomoinfo - * email: xiaomo@xiaomo.info - - * Date: 2016年11月3日 14:34 - * Copyright(©) 2015 by xiaomo. - **/ - -@Service -public class WorksServiceImpl implements WorksService { - - private WorksDao dao; - - @Autowired - public WorksServiceImpl(WorksDao dao) { - this.dao = dao; - } - - @Override - public List findAll() { - return dao.findAll(); - } - - @Override - public Page findAll(int start, int pageSize) { - return dao.findAll(new PageRequest(start - 1, pageSize)); - } - - @Override - public WorksModel findById(Long id) { - return dao.findOne(id); - } - - @Override - public WorksModel findByName(String name) { - return dao.findWorkByName(name); - } - - @Override - public WorksModel update(WorksModel model) { - WorksModel result = dao.findOne(model.getId()); - if (result == null) { - return null; - } - if ("".equals(model.getCompleteTime()) && model.getCompleteTime() != null) { - result.setCompleteTime(model.getCompleteTime()); - } - if ("".equals(model.getImgUrl()) && model.getImgUrl() != null) { - result.setImgUrl(model.getImgUrl()); - } - if ("".equals(model.getName()) && model.getName() != null) { - result.setName(model.getName()); - } - if ("".equals(model.getSummary()) && model.getSummary() != null) { - result.setSummary(model.getSummary()); - } - if ("".equals(model.getUrl()) && model.getUrl() != null) { - result.setUrl(model.getUrl()); - } - result.setUpdateTime(new Date()); - return dao.save(result); - } - - @Override - public WorksModel add(WorksModel model) { - model.setCreateTime(new Date()); - model.setUpdateTime(new Date()); - return dao.save(model); - } - - @Override - public void del(Long id) { - dao.delete(id); - } -} diff --git a/api/src/main/resources/config/application.properties b/api/src/main/resources/config/application.properties deleted file mode 100644 index 7191cb3e..00000000 --- a/api/src/main/resources/config/application.properties +++ /dev/null @@ -1,45 +0,0 @@ -logging.config=classpath:config/logback-dev.xml -server.port=8080 -server.session.timeout=1800 -server.max-http-header-size=20971520 - -#datasource -spring.datasource.url=jdbc:mysql://106.15.188.160/xiaomo?characterEncoding=utf8&useSSL=true -spring.datasource.username=xiaomo -spring.datasource.password=xiaomo -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -# \u914D\u7F6E\u8FD9\u4E2A\u503C\u5C31\u53EF\u4EE5\u683C\u5F0F\u5316\u65F6\u95F4 -#spring.jackson.date-format=yyyy-MM-dd HH:mm:ss -#spring.jackson.time-zone=GMT+8 - -#jpa -spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect -spring.jpa.hibernate.ddl-auto=update -spring.jpa.show-sql=true - - - -# redis -# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09 -spring.redis.database=0 -spring.redis.host=ip -spring.redis.port=6379 -spring.redis.password= -# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09 -spring.redis.pool.max-active=8 -# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09 -spring.redis.pool.max-wait=-1 -# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5 -spring.redis.pool.max-idle=8 -# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5 -spring.redis.pool.min-idle=0 -# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09 -spring.redis.timeout=0 - -#\u90AE\u4EF6 -spring.mail.host=smtp.qq.com -spring.mail.username= -spring.mail.password= -spring.mail.properties.mail.smtp.auth=true -spring.mail.properties.mail.smtp.starttls.enable=true -spring.mail.properties.mail.smtp.starttls.required=true diff --git a/async/pom.xml b/async/pom.xml index d2faf39b..60d54b74 100644 --- a/async/pom.xml +++ b/async/pom.xml @@ -5,7 +5,7 @@ xiaomo info.xiaomo - 2017.1 + 2020.1 4.0.0 @@ -14,7 +14,7 @@ info.xiaomo core - 2017.1 + 2020.1 @@ -23,6 +23,13 @@ org.springframework.boot spring-boot-maven-plugin + + + + repackage + + + diff --git a/async/src/main/java/info/xiaomo/anysc/AsyncMain.java b/async/src/main/java/info/xiaomo/anysc/AsyncMain.java index 51820745..79e1fce0 100644 --- a/async/src/main/java/info/xiaomo/anysc/AsyncMain.java +++ b/async/src/main/java/info/xiaomo/anysc/AsyncMain.java @@ -13,18 +13,18 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年4月1日 15:38 * Description: RabbitMq启动器 * Copyright(©) 2015 by xiaomo. **/ @Configuration -@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}) +@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) @ComponentScan("info.xiaomo") @EntityScan("info.xiaomo.*.model") public class AsyncMain { diff --git a/async/src/main/java/info/xiaomo/anysc/controller/TestController.java b/async/src/main/java/info/xiaomo/anysc/controller/TestController.java index 709049b6..0817a3a8 100644 --- a/async/src/main/java/info/xiaomo/anysc/controller/TestController.java +++ b/async/src/main/java/info/xiaomo/anysc/controller/TestController.java @@ -14,12 +14,12 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年11月15日 15:12 * Description: 用户实体类 * Copyright(©) 2015 by xiaomo. diff --git a/async/src/main/java/info/xiaomo/anysc/task/AsyncTask.java b/async/src/main/java/info/xiaomo/anysc/task/AsyncTask.java index cee66fd7..73ac1fc5 100644 --- a/async/src/main/java/info/xiaomo/anysc/task/AsyncTask.java +++ b/async/src/main/java/info/xiaomo/anysc/task/AsyncTask.java @@ -7,10 +7,13 @@ import java.util.Random; import java.util.concurrent.Future; +/** + * @author : xiaomo + */ @Component public class AsyncTask { - private static Random random =new Random(); + private static Random random = new Random(); @Async public Future doTaskOne() throws Exception { diff --git a/async/src/main/resources/config/application.properties b/async/src/main/resources/config/application.properties index 2bbf0e38..79ef9397 100644 --- a/async/src/main/resources/config/application.properties +++ b/async/src/main/resources/config/application.properties @@ -1,8 +1,9 @@ logging.config=classpath:config/logback-dev.xml server.port=8080 -server.session.timeout=1800 + server.max-http-header-size=20971520 # \u914D\u7F6E\u8FD9\u4E2A\u503C\u5C31\u53EF\u4EE5\u683C\u5F0F\u5316\u65F6\u95F4 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.time-zone=GMT+8 +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml index f36c7119..8e3af9eb 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ info.xiaomo xiaomo - 2017.1 + 2020.1 4.0.0 @@ -84,4 +84,18 @@ poi + + + + + org.springframework.boot + spring-boot-maven-plugin + + + none + + + + + \ No newline at end of file diff --git a/core/src/main/java/info/xiaomo/core/base/AuthOperate.java b/core/src/main/java/info/xiaomo/core/base/AuthOperate.java index 78cc964c..76889389 100644 --- a/core/src/main/java/info/xiaomo/core/base/AuthOperate.java +++ b/core/src/main/java/info/xiaomo/core/base/AuthOperate.java @@ -5,7 +5,7 @@ import java.util.Date; /** - * author 小莫 (https://xiaomo.info) (https://github.com/xiaomoinfo) + * @author : xiaomo (https://xiaomo.info) (https://github.com/houko) * @version : 2017年1月13日 9:51 */ public interface AuthOperate { diff --git a/core/src/main/java/info/xiaomo/core/base/BaseController.java b/core/src/main/java/info/xiaomo/core/base/BaseController.java index a1b0b739..b2f5d2c8 100644 --- a/core/src/main/java/info/xiaomo/core/base/BaseController.java +++ b/core/src/main/java/info/xiaomo/core/base/BaseController.java @@ -10,7 +10,7 @@ import java.util.List; /** - * author 小莫 (https://xiaomo.info) (https://github.com/xiaomoinfo) + * @author : xiaomo (https://xiaomo.info) (https://github.com/houko) * @version : 2017年1月11日 16:41 */ @RestController diff --git a/core/src/main/java/info/xiaomo/core/base/BaseDao.java b/core/src/main/java/info/xiaomo/core/base/BaseDao.java index 00fdc512..d9c6941a 100644 --- a/core/src/main/java/info/xiaomo/core/base/BaseDao.java +++ b/core/src/main/java/info/xiaomo/core/base/BaseDao.java @@ -4,15 +4,25 @@ import org.springframework.stereotype.Repository; /** - * author 小莫 (https://xiaomo.info) (https://github.com/xiaomoinfo) + * @author : xiaomo (https://xiaomo.info) (https://github.com/houko) * @version : 2017年1月13日 11:23 */ @Repository public interface BaseDao extends JpaRepository { - T findById(Long id); - + /** + * 根据名字查 + * + * @param name + * @return + */ T findByName(String name); + /** + * 删除 + * + * @param name + * @return + */ boolean deleteByName(String name); } diff --git a/core/src/main/java/info/xiaomo/core/base/BaseModel.java b/core/src/main/java/info/xiaomo/core/base/BaseModel.java index 41de675a..37d18bbe 100644 --- a/core/src/main/java/info/xiaomo/core/base/BaseModel.java +++ b/core/src/main/java/info/xiaomo/core/base/BaseModel.java @@ -10,12 +10,12 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年4月1日 20:37 * Copyright(©) 2015 by xiaomo. **/ diff --git a/core/src/main/java/info/xiaomo/core/base/BaseService.java b/core/src/main/java/info/xiaomo/core/base/BaseService.java index 59407108..4ff3a02f 100644 --- a/core/src/main/java/info/xiaomo/core/base/BaseService.java +++ b/core/src/main/java/info/xiaomo/core/base/BaseService.java @@ -6,27 +6,81 @@ import java.util.List; /** - * author 小莫 (https://xiaomo.info) (https://github.com/xiaomoinfo) + * @author : xiaomo (https://xiaomo.info) (https://github.com/houko) * @version : 2017年1月11日 16:42 */ @Service public interface BaseService { + /** + * 根据id查 + * + * @param id + * @return + */ T findById(Long id); + /** + * 根据名字查 + * + * @param name + * @return + */ T findByName(String name); + /** + * 查找所有 + * + * @return + */ List findAll(); + /** + * 分页查询 + * + * @param start + * @param pageSize + * @return + */ Page findAll(int start, int pageSize); + /** + * 根据id删除 + * + * @param id + * @return + */ boolean deleteById(Long id); + /** + * 根据名字删除 + * + * @param name + * @return + */ boolean deleteByName(String name); + /** + * 增加 + * + * @param model + * @return + */ boolean add(T model); + /** + * 更新 + * + * @param model + * @return + */ boolean update(T model); + /** + * 批量删除 + * + * @param ids + * @return + */ boolean deleteByIds(List ids); } diff --git a/core/src/main/java/info/xiaomo/core/base/Result.java b/core/src/main/java/info/xiaomo/core/base/Result.java index 04ae26c9..4ec1cb45 100644 --- a/core/src/main/java/info/xiaomo/core/base/Result.java +++ b/core/src/main/java/info/xiaomo/core/base/Result.java @@ -6,12 +6,12 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年10月31日 15:25 * Description: 返回结果 * Copyright(©) 2015 by xiaomo. diff --git a/core/src/main/java/info/xiaomo/core/constant/CodeConst.java b/core/src/main/java/info/xiaomo/core/constant/CodeConst.java index 133fea5d..9b411ca5 100644 --- a/core/src/main/java/info/xiaomo/core/constant/CodeConst.java +++ b/core/src/main/java/info/xiaomo/core/constant/CodeConst.java @@ -4,17 +4,20 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年10月29日 10:59 * Description: 错误码 * Copyright(©) 2015 by xiaomo. */ public enum CodeConst { + /** + * success + */ SUCCESS(200, "成功"), NOT_FOUNT(404, "找不到"), REPEAT(992, "数据重复"), diff --git a/core/src/main/java/info/xiaomo/core/constant/FileConst.java b/core/src/main/java/info/xiaomo/core/constant/FileConst.java index ddc052bd..c816674f 100644 --- a/core/src/main/java/info/xiaomo/core/constant/FileConst.java +++ b/core/src/main/java/info/xiaomo/core/constant/FileConst.java @@ -1,5 +1,9 @@ package info.xiaomo.core.constant; +/** + * @author qq + */ + public enum FileConst { /** * JEPG. @@ -148,11 +152,11 @@ public enum FileConst { */ MF("4D616E69666573742D56"), /** - *EXE Archive. + * EXE Archive. */ EXE("4D5A9000030000000400"), /** - *CHM Archive. + * CHM Archive. */ CHM("49545346030000006000"), /* @@ -219,7 +223,7 @@ public enum FileConst { * * @param value */ - private FileConst(String value) { + FileConst(String value) { this.value = value; } diff --git a/core/src/main/java/info/xiaomo/core/constant/GenderConst.java b/core/src/main/java/info/xiaomo/core/constant/GenderConst.java index 735f82c4..05694372 100644 --- a/core/src/main/java/info/xiaomo/core/constant/GenderConst.java +++ b/core/src/main/java/info/xiaomo/core/constant/GenderConst.java @@ -4,22 +4,22 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年1月12日 16:37 * Description: 性别 * Copyright(©) 2015 by xiaomo. **/ public interface GenderConst { - int secret = 0; + int SECRET = 0; - int man = 1; + int MAN = 1; - int woman = 2; + int WOMAN = 2; } diff --git a/core/src/main/java/info/xiaomo/core/constant/SymbolConst.java b/core/src/main/java/info/xiaomo/core/constant/SymbolConst.java index 46be4f6a..c4dbcfeb 100644 --- a/core/src/main/java/info/xiaomo/core/constant/SymbolConst.java +++ b/core/src/main/java/info/xiaomo/core/constant/SymbolConst.java @@ -1,5 +1,8 @@ package info.xiaomo.core.constant; +/** + * @author : xiaomo + */ public class SymbolConst { public static final String JINHAO = "#"; public static final String AND = "&"; diff --git a/core/src/main/java/info/xiaomo/core/exception/UserNotFoundException.java b/core/src/main/java/info/xiaomo/core/exception/UserNotFoundException.java index 277163ad..ee06bc04 100644 --- a/core/src/main/java/info/xiaomo/core/exception/UserNotFoundException.java +++ b/core/src/main/java/info/xiaomo/core/exception/UserNotFoundException.java @@ -12,12 +12,12 @@ * |╭---╮把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 16/4/3 11:08 * Description: 找不到用户异常 * Copyright(©) 2015 by xiaomo. diff --git a/core/src/main/java/info/xiaomo/core/field/LoginField.java b/core/src/main/java/info/xiaomo/core/field/LoginField.java index 6de80592..e6ea5173 100644 --- a/core/src/main/java/info/xiaomo/core/field/LoginField.java +++ b/core/src/main/java/info/xiaomo/core/field/LoginField.java @@ -4,64 +4,59 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info(83387856) * Date: 2016年1月8日 13:16 * Description: QQ登录常量类 * Copyright(©) 2015 by xiaomo. */ public interface LoginField { - //qq - String QQOpenId = "openid"; - String QQNickname = "nickname"; - String QQPhotourl = "figureurl_qq_2"; - String QQGender = "gender"; - //sina - String sinaNickName = "screen_name"; - String sinaOpenId = "id"; - String sinaHeadPhoto = "avatar_large"; - //github - String githubNickName = "name"; - String githubOpenId = "id"; - String githubHeadPhoto = "avatar_url"; - String githubEmail = "email"; - //baidu - String baiduNickName = "name"; - String baiduOpenId = "id"; - String baiduHeadPhoto = "avatar_url"; - String baiduGender = ""; - //osc - String oscNickName = "name"; - String oscOpenId = "id"; - String oscHeadPhoto = "avatar"; - String oscEmail = "email"; - String oscGender = "gender"; + String Q_Q_OPEN_ID = "openid"; + String Q_Q_NICKNAME = "nickname"; + String Q_Q_PHOTOURL = "figureurl_qq_2"; + String Q_Q_GENDER = "gender"; + String SINA_NICK_NAME = "screen_name"; + String SINA_OPEN_ID = "id"; + String SINA_HEAD_PHOTO = "avatar_large"; + String GITHUB_NICK_NAME = "name"; + String GITHUB_OPEN_ID = "id"; + String GITHUB_HEAD_PHOTO = "avatar_url"; + String GITHUB_EMAIL = "email"; + String BAIDU_NICK_NAME = "name"; + String BAIDU_OPEN_ID = "id"; + String BAIDU_HEAD_PHOTO = "avatar_url"; + String BAIDU_GENDER = ""; + + String OSC_NICK_NAME = "name"; + String OSC_OPEN_ID = "id"; + String OSC_HEAD_PHOTO = "avatar"; + String OSC_EMAIL = "email"; + String OSC_GENDER = "gender"; - //renren - String renrenNickName = "name"; - String renrenOpenId = "id"; - String renrenHeadPhoto = "url"; - String renrenEmail = "email"; - String renrenGender = "gender"; - String renrenPhoto = "avatar"; + String RENREN_NICK_NAME = "name"; + String RENREN_OPEN_ID = "id"; + String RENREN_HEAD_PHOTO = "url"; + String RENREN_EMAIL = "email"; + String RENREN_GENDER = "gender"; + String RENREN_PHOTO = "avatar"; - String id = "id"; - String password = "password"; - String email = "email"; - String emailVerify = "emailVerify"; // EmailVerifyConst 是否验证 - String sex = "gender"; //GenderType 性别 - String birthday = "birthday"; //GenderType 性别 - String status = "status"; // UserStatusType 帐号状态 - String lastLoginTime = "lastLoginTime"; + String ID = "id"; + String PASSWORD = "password"; + String EMAIL = "email"; + String EMAILVERIFY = "emailVerify"; + String SEX = "gender"; + String BIRTHDAY = "birthday"; + String STATUS = "status"; + String LAST_LOGIN_TIME = "lastLoginTime"; - String type = "type"; //LoginTypeConst 登录类型 - String contribution = "contribution"; - String authority = "authority"; // OauthType 权限类型 - String updateTime = "updateTime"; - String createTime = "createTime"; - String index = "/index.html"; + String TYPE = "type"; + String CONTRIBUTION = "contribution"; + String AUTHORITY = "authority"; + String UPDATETIME = "updateTime"; + String CREATETIME = "createTime"; + String INDEX = "/index.html"; } diff --git a/core/src/main/java/info/xiaomo/core/filter/CORSFilter.java b/core/src/main/java/info/xiaomo/core/filter/CorsFilter.java similarity index 92% rename from core/src/main/java/info/xiaomo/core/filter/CORSFilter.java rename to core/src/main/java/info/xiaomo/core/filter/CorsFilter.java index fd39f152..75ccacf3 100644 --- a/core/src/main/java/info/xiaomo/core/filter/CORSFilter.java +++ b/core/src/main/java/info/xiaomo/core/filter/CorsFilter.java @@ -10,18 +10,18 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016/4/1516:25 * Description: * Copyright(©) 2015 by xiaomo. **/ @Component -public class CORSFilter implements Filter { +public class CorsFilter implements Filter { /** @@ -44,6 +44,7 @@ public void init(FilterConfig filterConfig) throws ServletException { * @throws IOException IOException * @throws ServletException ServletException */ + @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); @@ -57,6 +58,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) /** * 销毁对象 */ + @Override public void destroy() { } } diff --git a/core/src/main/java/info/xiaomo/core/filter/CustomDateSerializerFilter.java b/core/src/main/java/info/xiaomo/core/filter/CustomDateSerializerFilter.java index 8c58cadd..e46cfb8f 100644 --- a/core/src/main/java/info/xiaomo/core/filter/CustomDateSerializerFilter.java +++ b/core/src/main/java/info/xiaomo/core/filter/CustomDateSerializerFilter.java @@ -9,6 +9,9 @@ import java.text.SimpleDateFormat; import java.util.Date; +/** + * @author : xiaomo + */ public class CustomDateSerializerFilter extends JsonSerializer { @Override diff --git a/core/src/main/java/info/xiaomo/core/untils/AuthUtil.java b/core/src/main/java/info/xiaomo/core/untils/AuthUtil.java index b1e95418..670f0d70 100644 --- a/core/src/main/java/info/xiaomo/core/untils/AuthUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/AuthUtil.java @@ -6,12 +6,12 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * @email: xiaomo@xiaomo.info - + *

* Date: 20161131 9:50 * Copyright(©) 2015 by xiaomo. **/ diff --git a/core/src/main/java/info/xiaomo/core/untils/CastUtil.java b/core/src/main/java/info/xiaomo/core/untils/CastUtil.java index a95027e2..a3c19f4c 100644 --- a/core/src/main/java/info/xiaomo/core/untils/CastUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/CastUtil.java @@ -2,6 +2,7 @@ import java.io.*; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; @@ -10,18 +11,18 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. + * - * author: xiaomo - * github: https://github.com/xiaomoinfo + * @author : xiaomo + * github: https://github.com/houko * email: xiaomo@xiaomo.info - + *

* Date: 2016年11月22日 14:55 * Copyright(©) 2015 by xiaomo. **/ public class CastUtil { - protected static final ByteArrayOutputStream out = new ByteArrayOutputStream(); + protected static final ByteArrayOutputStream OUT = new ByteArrayOutputStream(); protected static ObjectOutputStream oos; public CastUtil() { @@ -119,7 +120,7 @@ public static int isNumeric(String str) { } public static HashMap copyMap(HashMap map) { - HashMap newmap = new HashMap(); + HashMap newmap = new HashMap(10); for (Object key : map.keySet()) { newmap.put(key, map.get(key)); @@ -162,7 +163,7 @@ public static String objectToString(Object obj) { ObjectOutputStream e = new ObjectOutputStream(out); e.writeObject(obj); byte[] bytes = out.toByteArray(); - return new String(bytes, "ISO-8859-1"); + return new String(bytes, StandardCharsets.ISO_8859_1); } catch (IOException var4) { var4.printStackTrace(); return null; @@ -172,7 +173,7 @@ public static String objectToString(Object obj) { public static Object stringToObject(String string) { try { - byte[] e = string.getBytes("ISO-8859-1"); + byte[] e = string.getBytes(StandardCharsets.ISO_8859_1); ByteArrayInputStream in = new ByteArrayInputStream(e); ObjectInputStream ois = new ObjectInputStream(in); return ois.readObject(); @@ -208,20 +209,20 @@ public static Object bytesToObject(byte[] bytes) { } public static byte[] objectToBytes(Object obj) throws IOException { - out.reset(); + OUT.reset(); byte[] var2; try { if (oos == null) { - oos = new ObjectOutputStream(out); + oos = new ObjectOutputStream(OUT); } else { oos.reset(); } oos.writeObject(obj); - var2 = out.toByteArray(); + var2 = OUT.toByteArray(); } finally { - out.close(); + OUT.close(); } return var2; @@ -290,7 +291,7 @@ public static int[] stringToInts(String str, String regex) { } public static String bytesToHexString(byte[] src) { - StringBuilder stringBuilder = new StringBuilder(""); + StringBuilder stringBuilder = new StringBuilder(); if (src != null && src.length> 0) { for (byte aSrc : src) { int v = aSrc & 255; @@ -309,7 +310,7 @@ public static String bytesToHexString(byte[] src) { } public static byte[] hexStringToBytes(String hexString) { - if (hexString != null && !hexString.equals("")) { + if (hexString != null && !"".equals(hexString)) { hexString = hexString.toUpperCase(); int length = hexString.length() / 2; char[] hexChars = hexString.toCharArray(); @@ -330,7 +331,7 @@ public static double strToDouble(String str) { if (str != null && !str.isEmpty()) { int len = str.length(); int p = str.indexOf(37); - return p == len - 1 ? Double.valueOf(str.substring(0, len - 1)) / 100.0D : (p> -1 ? 0.0D : (str.equals("true") ? 1.0D : toDouble(str))); + return p == len - 1 ? Double.valueOf(str.substring(0, len - 1)) / 100.0D : (p> -1 ? 0.0D : ("true".equals(str) ? 1.0D : toDouble(str))); } else { return 0.0D; } diff --git a/core/src/main/java/info/xiaomo/core/untils/CharUtil.java b/core/src/main/java/info/xiaomo/core/untils/CharUtil.java index 846fecbe..17b3e973 100644 --- a/core/src/main/java/info/xiaomo/core/untils/CharUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/CharUtil.java @@ -1,23 +1,24 @@ package info.xiaomo.core.untils; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Objects; /** *

Title:字符编码工具类

* + * @author : xiaomo * @version 1.0 - * author: xiaomo */ public class CharUtil { /** * 转换编码 ISO-8859-1到GB2312 */ - public static String ISO2GB(String text) { + public static String iso2gb(String text) { String result; try { - result = new String(text.getBytes("ISO-8859-1"), "GB2312"); + result = new String(text.getBytes(StandardCharsets.ISO_8859_1), "GB2312"); } catch (UnsupportedEncodingException ex) { result = ex.toString(); } @@ -27,10 +28,10 @@ public static String ISO2GB(String text) { /** * 转换编码 GB2312到ISO-8859-1 */ - public static String GB2ISO(String text) { + public static String gb2iso(String text) { String result = ""; try { - result = new String(text.getBytes("GB2312"), "ISO-8859-1"); + result = new String(text.getBytes("GB2312"), StandardCharsets.ISO_8859_1); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } @@ -40,7 +41,7 @@ public static String GB2ISO(String text) { /** * Utf8URL编码 */ - public static String Utf8URLEncode(String text) { + public static String utf8urlencode(String text) { StringBuilder result = new StringBuilder(); for (int i = 0; i < text.length(); i++) { @@ -51,13 +52,15 @@ public static String Utf8URLEncode(String text) { byte[] b = new byte[0]; try { - b = Character.toString(c).getBytes("UTF-8"); + b = Character.toString(c).getBytes(StandardCharsets.UTF_8); } catch (Exception ignored) { } for (byte aB : b) { int k = aB; - if (k < 0) k += 256; + if (k < 0) { + k += 256; + } result.append("%").append(Integer.toHexString(k).toUpperCase()); } @@ -69,19 +72,23 @@ public static String Utf8URLEncode(String text) { /** * Utf8URL解码 */ - public static String Utf8URLDecode(String text) { - String result = ""; + public static String utf8urldecode(String text) { + StringBuilder result = new StringBuilder(); int p; if (text != null && text.length()> 0) { text = text.toLowerCase(); p = text.indexOf("%e"); - if (p == -1) return text; + if (p == -1) { + return text; + } while (p != -1) { - result += text.substring(0, p); - text = text.substring(p, text.length()); - if (Objects.equals(text, "") || text.length() < 9) return result; - result += CodeToWord(text.substring(0, 9)); - text = text.substring(9, text.length()); + result.append(text, 0, p); + text = text.substring(p); + if (Objects.equals(text, "") || text.length() < 9) { + return result.toString(); + } + result.append(codetoword(text.substring(0, 9))); + text = text.substring(9); p = text.indexOf("%e"); } } @@ -91,18 +98,14 @@ public static String Utf8URLDecode(String text) { /** * utf8URL编码转字符 */ - private static String CodeToWord(String text) { + private static String codetoword(String text) { String result; - if (Utf8codeCheck(text)) { + if (utf8codecheck(text)) { byte[] code = new byte[3]; code[0] = (byte) (Integer.parseInt(text.substring(1, 3), 16) - 256); code[1] = (byte) (Integer.parseInt(text.substring(4, 6), 16) - 256); code[2] = (byte) (Integer.parseInt(text.substring(7, 9), 16) - 256); - try { - result = new String(code, "UTF-8"); - } catch (UnsupportedEncodingException ex) { - result = null; - } + result = new String(code, StandardCharsets.UTF_8); } else { result = text; } @@ -112,17 +115,19 @@ private static String CodeToWord(String text) { /** * 编码是否有效 */ - private static boolean Utf8codeCheck(String text) { + private static boolean utf8codecheck(String text) { String sign = ""; - if (text.startsWith("%e")) { + String prefix = "%e"; + if (text.startsWith(prefix)) { for (int p = 0; p != -1; ) { p = text.indexOf("%", p); - if (p != -1) + if (p != -1) { p++; + } sign += p; } } - return sign.equals("147-1"); + return "147-1".equals(sign); } /** @@ -131,10 +136,11 @@ private static boolean Utf8codeCheck(String text) { public static boolean isUtf8Url(String text) { text = text.toLowerCase(); int p = text.indexOf("%"); - if (p != -1 && text.length() - p> 9) { - text = text.substring(p, p + 9); + int nine = 9; + if (p != -1 && text.length() - p> nine) { + text = text.substring(p, p + nine); } - return Utf8codeCheck(text); + return utf8codecheck(text); } /** @@ -147,24 +153,28 @@ public static char regularize(char input) { input = (char) 32; } else if (input> 65280 && input < 65375) { input = (char) (input - 65248); - } else if (input>= 'A' && input <= 'Z') { - input += 32; + } else { + char a = 'A'; + char z = 'Z'; + if (input>= a && input <= z) { + input += 32; + } } return input; } public static void main(String[] args) { String url; - System.out.println(Utf8URLEncode("小莫")); - System.out.println(ISO2GB("小莫")); - System.out.println(GB2ISO("小莫")); + System.out.println(utf8urlencode("小莫")); + System.out.println(iso2gb("小莫")); + System.out.println(gb2iso("小莫")); url = "http://www.google.com/search?hl=zh-CN&newwindow=1&q=%E4%B8%AD%E5%9B%BD%E5%A4%A7%E7%99%BE%E7%A7%91%E5%9C%A8%E7%BA%BF%E5%85%A8%E6%96%87%E6%A3%80%E7%B4%A2&btnG=%E6%90%9C%E7%B4%A2&lr="; if (CharUtil.isUtf8Url(url)) { - System.out.println(CharUtil.Utf8URLDecode(url)); + System.out.println(CharUtil.utf8urldecode(url)); } url = "http://www.baidu.com/baidu?word=%D6%D0%B9%FA%B4%F3%B0%D9%BF%C6%D4%DA%CF%DF%C8%AB%CE%C4%BC%EC%CB%F7&tn=myie2dg"; if (CharUtil.isUtf8Url(url)) { - System.out.println(CharUtil.Utf8URLDecode(url)); + System.out.println(CharUtil.utf8urldecode(url)); } } diff --git a/core/src/main/java/info/xiaomo/core/untils/DownUtil.java b/core/src/main/java/info/xiaomo/core/untils/DownUtil.java index 3770c956..3f6d64e0 100644 --- a/core/src/main/java/info/xiaomo/core/untils/DownUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/DownUtil.java @@ -10,8 +10,7 @@ import java.net.URLConnection; /** - * author 小莫 (https://xiaomo.info) (https://github.com/xiaomoinfo) - * + * @author : xiaomo (https://xiaomo.info) (https://github.com/houko) * @created : 2016/12/26 13:25 */ @Slf4j @@ -64,10 +63,10 @@ public static void download(String urlString, String filePath) throws Exception // 输出的文件流 File output = new File(filePath); - if (!output.exists()){ + if (!output.exists()) { boolean res = output.mkdir(); - if (res){ - log.debug("{} 目录创建成功", filePath); + if (res) { + log.debug("{} 目录创建成功", filePath); } } diff --git a/core/src/main/java/info/xiaomo/core/untils/ExcelUtil.java b/core/src/main/java/info/xiaomo/core/untils/ExcelUtil.java index f51f794c..9a1738e3 100644 --- a/core/src/main/java/info/xiaomo/core/untils/ExcelUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/ExcelUtil.java @@ -11,6 +11,9 @@ import java.util.Date; import java.util.List; +/** + * @author : xiaomo + */ public class ExcelUtil { // // public static void main(String[] args) throws Exception { @@ -32,7 +35,7 @@ public static List> getListData(String path, int ignoreRows) throws for (String[] aResult : result) { List list = new ArrayList(); for (String anAResult : aResult) { - if (!anAResult.equals("")) { + if (!"".equals(anAResult)) { list.add(anAResult); } } @@ -99,7 +102,7 @@ private static String[][] getData(File file, int ignoreRows) break; case HSSFCell.CELL_TYPE_FORMULA: // 导入时如果为公式生成的数据则无值 - if (!cell.getStringCellValue().equals("")) { + if (!"".equals(cell.getStringCellValue())) { value = cell.getStringCellValue(); } else { value = cell.getNumericCellValue() + ""; @@ -118,7 +121,7 @@ private static String[][] getData(File file, int ignoreRows) value = ""; } } - if (columnIndex == 0 && value.trim().equals("")) { + if (columnIndex == 0 && "".equals(value.trim())) { break; } values[columnIndex] = rightTrim(value); diff --git a/core/src/main/java/info/xiaomo/core/untils/FileUtil.java b/core/src/main/java/info/xiaomo/core/untils/FileUtil.java index f9ebcefd..d0297bf5 100644 --- a/core/src/main/java/info/xiaomo/core/untils/FileUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/FileUtil.java @@ -15,6 +15,7 @@ * 所有方法都是静态方法,不需要生成此类的实例, * 为避免生成此类的实例,构造方法被申明为private类型的。 * + * @author : xiaomo * @since 1.0 */ @@ -510,7 +511,8 @@ public static boolean pathValidate(String path) { for (String anArraypath : arraypath) { tmppath += "/" + anArraypath; File d = new File(tmppath.substring(1)); - if (!d.exists()) { //检查Sub目录是否存在 + //检查Sub目录是否存在 + if (!d.exists()) { System.out.println(tmppath.substring(1)); if (!d.mkdir()) { return false; @@ -542,7 +544,8 @@ public static boolean genModuleTpl(String path, String modulecontent) throws IOE return false; } } - FileWriter fw = new FileWriter(path); //建立FileWriter对象,并实例化fw + //建立FileWriter对象,并实例化fw + FileWriter fw = new FileWriter(path); //将字符串写入文件 fw.write(modulecontent); fw.close(); @@ -552,30 +555,34 @@ public static boolean genModuleTpl(String path, String modulecontent) throws IOE /** * 获取图片文件的扩展名(发布系统专用) * - * @param pic_path 为图片名称加上前面的路径不包括扩展名 + * @param picPath 为图片名称加上前面的路径不包括扩展名 * @return 图片的扩展名 * @since 1.0 */ - public static String getPicExtendName(String pic_path) { - pic_path = getUNIXfilePath(pic_path); - String pic_extend = ""; - if (isFileExist(pic_path + ".gif")) { - pic_extend = ".gif"; + public static String getPicExtendName(String picPath) { + picPath = getUNIXfilePath(picPath); + String picExtend = ""; + String gif = ".gif"; + if (isFileExist(picPath + gif)) { + picExtend = gif; } - if (isFileExist(pic_path + ".jpeg")) { - pic_extend = ".jpeg"; + String jpeg = ".jpeg"; + if (isFileExist(picPath + jpeg)) { + picExtend = jpeg; } - if (isFileExist(pic_path + ".jpg")) { - pic_extend = ".jpg"; + String jpg = ".jpg"; + if (isFileExist(picPath + jpg)) { + picExtend = jpg; } - if (isFileExist(pic_path + ".png")) { - pic_extend = ".png"; + String png = ".png"; + if (isFileExist(picPath + png)) { + picExtend = png; } - return pic_extend; //返回图片扩展名 + //返回图片扩展名 + return picExtend; } - //拷贝文件 - public static boolean CopyFile(File in, File out) throws Exception { + public static boolean copyFile(File in, File out) throws Exception { try { FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); @@ -593,12 +600,11 @@ public static boolean CopyFile(File in, File out) throws Exception { } } - //拷贝文件 - public static boolean CopyFile(String infile, String outfile) throws Exception { + public static boolean copyFile(String infile, String outfile) throws Exception { try { File in = new File(infile); File out = new File(outfile); - return CopyFile(in, out); + return copyFile(in, out); } catch (IOException ie) { ie.printStackTrace(); return false; @@ -612,7 +618,7 @@ public static boolean CopyFile(String infile, String outfile) throws Exception { * @param in data source * @param out data destination * @throws IOException in an input or output error occurs - * @since ostermillerutils 1.00.00 + * @since orientals 1.00.00 */ private static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; @@ -638,7 +644,7 @@ private static void list(List list, File file, } } if (file.isDirectory()) { - File files[] = file.listFiles(); + File[] files = file.listFiles(); for (File file1 : files != null ? files : new File[0]) { list(list, file1, filter); } @@ -821,23 +827,18 @@ public static FileConst getType(String filePath) throws IOException { } public static String getNewFileName(String fileName, String email) { - String FileType = FileUtil.getFileType(fileName); + String fileType = FileUtil.getFileType(fileName); String newName = email.split(SymbolConst.AT)[0]; - return (TimeUtil.getDateNow(TimeUtil.DATE_FORMAT_STRING) + SymbolConst.HENGXIAN + newName + SymbolConst.DIAN + FileType).toLowerCase(); + return (TimeUtil.getDateNow(TimeUtil.DATE_FORMAT_STRING) + SymbolConst.HENGXIAN + newName + SymbolConst.DIAN + fileType).toLowerCase(); } public static boolean isImage(String imageName) { String fileType = FileUtil.getFileType(imageName); - return !(fileType.equals("bmp") || fileType.equals("BMP") - || fileType.equals("jpg") || fileType.equals("JPG") - || fileType.equals("jpeg") || fileType.equals("JPEG") - || fileType.equals("git") || fileType.equals("GIF") - || fileType.equals("png") || fileType.equals("PNG")); - } - - public static void main(String args[]) throws Exception { - System.out.println(TimeUtil.getDateNow(TimeUtil.DATE_FORMAT_STRING)); - System.out.println(getType("E:\\oscchina\\xiaomoBlogJava\\core\\src\\main\\java\\info\\xiaomo\\core\\constant\\GenderConst.java")); + return !("bmp".equals(fileType) || "BMP".equals(fileType) + || "jpg".equals(fileType) || "JPG".equals(fileType) + || "jpeg".equals(fileType) || "JPEG".equals(fileType) + || "git".equals(fileType) || "GIF".equals(fileType) + || "png".equals(fileType) || "PNG".equals(fileType)); } } diff --git a/core/src/main/java/info/xiaomo/core/untils/HtmlUtil.java b/core/src/main/java/info/xiaomo/core/untils/HtmlUtil.java index d76370f1..975e56ac 100644 --- a/core/src/main/java/info/xiaomo/core/untils/HtmlUtil.java +++ b/core/src/main/java/info/xiaomo/core/untils/HtmlUtil.java @@ -7,9 +7,9 @@ * 把今天最好的表现当作明天最新的起点..〜 * いま 最高の表現 として 明日最新の始発..〜 * Today the best performance as tomorrow newest starter! - * Created by IntelliJ IDEA. *

- * author: xiaomo + * + * @author : xiaomo * github: https://github.com/syoubaku * email: xiaomo@xiamoo.info * QQ_NO: 83387856 @@ -47,26 +47,28 @@ public static boolean containsHTMLTag(String str) { */ public static String htmlEncode(String strSrc) { - if (strSrc == null) + if (strSrc == null) { return ""; - char[] arr_cSrc = strSrc.toCharArray(); - StringBuilder buf = new StringBuilder(arr_cSrc.length); + } + char[] arrCsrc = strSrc.toCharArray(); + StringBuilder buf = new StringBuilder(arrCsrc.length); char ch; - for (char anArr_cSrc : arr_cSrc) { - ch = anArr_cSrc; + for (char anArrCSrc : arrCsrc) { + ch = anArrCSrc; - if (ch == '<') + if (ch == '<') { buf.append("<"); - else if (ch == '>') + } else if (ch == '>') { buf.append(">"); - else if (ch == '"') + } else if (ch == '"') { buf.append("""); - else if (ch == '\'') + } else if (ch == '\'') { buf.append("'"); - else if (ch == '&') + } else if (ch == '&') { buf.append("&"); - else + } else { buf.append(ch); + } } return buf.toString(); @@ -83,30 +85,32 @@ else if (ch == '&') */ public static String htmlEncode(String strSrc, int quotes) { - if (strSrc == null) + if (strSrc == null) { return ""; + } if (quotes == 0) { return htmlEncode(strSrc); } - char[] arr_cSrc = strSrc.toCharArray(); - StringBuilder buf = new StringBuilder(arr_cSrc.length); + char[] arrCsrc = strSrc.toCharArray(); + StringBuilder buf = new StringBuilder(arrCsrc.length); char ch; - for (int i = 0; i < arr_cSrc.length; i++) { - ch = arr_cSrc[i]; - if (ch == '<') + for (int i = 0; i < arrCsrc.length; i++) { + ch = arrCsrc[i]; + if (ch == '<') { buf.append("<"); - else if (ch == '>') + } else if (ch == '>') { buf.append(">"); - else if (ch == '"' && quotes == 1) + } else if (ch == '"' && quotes == 1) { buf.append("""); - else if (ch == '\'' && quotes == 2) + } else if (ch == '\'' && quotes == 2) { buf.append("'"); - else if (ch == '&') + } else if (ch == '&') { buf.append("&"); - else + } else { buf.append(ch); + } } return buf.toString(); @@ -120,8 +124,9 @@ else if (ch == '&') * @since 1.0 */ public static String htmlDecode(String strSrc) { - if (strSrc == null) + if (strSrc == null) { return ""; + } strSrc = strSrc.replaceAll("<", "<"); strSrc = strSrc.replaceAll(">", ">"); strSrc = strSrc.replaceAll(""", "\""); @@ -137,23 +142,29 @@ public static String htmlDecode(String strSrc) { * @return string */ public static String delHTMLTag(String htmlStr) { - String regEx_script = " -

AltStyle によって変換されたページ (->オリジナル) /

- \ No newline at end of file diff --git a/website/src/main/resources/templates/index.ftl b/website/src/main/resources/templates/index.ftl index 6aabfeb4..1b40b282 100644 --- a/website/src/main/resources/templates/index.ftl +++ b/website/src/main/resources/templates/index.ftl @@ -101,8 +101,8 @@ diff --git a/website/src/test/java/info/xiaomo/test/MailTests.java b/website/src/test/java/info/xiaomo/test/MailTests.java deleted file mode 100644 index 3bff1dd0..00000000 --- a/website/src/test/java/info/xiaomo/test/MailTests.java +++ /dev/null @@ -1,71 +0,0 @@ -package info.xiaomo.test; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.FileSystemResource; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.MimeMessageHelper; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.mail.internet.MimeMessage; -import java.io.File; - - -@RunWith(SpringJUnit4ClassRunner.class) -public class MailTests { - - @Autowired - private JavaMailSender mailSender; - - - @Test - public void sendSimpleMail() throws Exception { - - SimpleMailMessage message = new SimpleMailMessage(); - message.setFrom("dyc87112@qq.com"); - message.setTo("dyc87112@qq.com"); - message.setSubject("主题:简单邮件"); - message.setText("测试邮件内容"); - - mailSender.send(message); - } - - @Test - public void sendAttachmentsMail() throws Exception { - - MimeMessage mimeMessage = mailSender.createMimeMessage(); - - MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); - helper.setFrom("dyc87112@qq.com"); - helper.setTo("dyc87112@qq.com"); - helper.setSubject("主题:有附件"); - helper.setText("有附件的邮件"); - - FileSystemResource file = new FileSystemResource(new File("weixin.jpg")); - helper.addAttachment("附件-1.jpg", file); - helper.addAttachment("附件-2.jpg", file); - - mailSender.send(mimeMessage); - } - - @Test - public void sendInlineMail() throws Exception { - - MimeMessage mimeMessage = mailSender.createMimeMessage(); - - MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); - helper.setFrom("dyc87112@qq.com"); - helper.setTo("dyc87112@qq.com"); - helper.setSubject("主题:嵌入静态资源"); - helper.setText("", true); - - FileSystemResource file = new FileSystemResource(new File("weixin.jpg")); - helper.addInline("weixin", file); - - mailSender.send(mimeMessage); - } - - -} diff --git a/website/src/test/resources/application.properties b/website/src/test/resources/application.properties deleted file mode 100644 index 6a4f05b0..00000000 --- a/website/src/test/resources/application.properties +++ /dev/null @@ -1,33 +0,0 @@ -logging.config=classpath:config/logback-dev.xml -server.port=8080 -server.session.timeout=1800 -server.max-http-header-size=20971520 - -#datasource -spring.datasource.url=jdbc:mysql://ip/\u6570\u636E\u5E93?characterEncoding=utf8&useSSL=true -# ?useUnicode=true&characterEncoding=UTF-8 -spring.datasource.username=\u4F60\u7684\u5E10\u53F7 -spring.datasource.password=\u4F60\u7684\u5BC6\u7801 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -# \u914D\u7F6E\u8FD9\u4E2A\u503C\u5C31\u53EF\u4EE5\u683C\u5F0F\u5316\u65F6\u95F4 -#spring.jackson.date-format=yyyy-MM-dd HH:mm:ss -#spring.jackson.time-zone=GMT+8 - -#jpa -spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect -spring.jpa.hibernate.ddl-auto=update -spring.jpa.show-sql=true - - - -#\u90AE\u4EF6 -spring.mail.host=smtp.qq.com -spring.mail.username=83387856@qq.com -spring.mail.password=, -spring.mail.properties.mail.smtp.auth=true -spring.mail.properties.mail.smtp.starttls.enable=true -spring.mail.properties.mail.smtp.starttls.required=true - -#spring.data.mongodb.uri=mongodb://name:pass@localhost:27017/test - -