├── .gitattributes ├── .gitignore ├── .idea ├── .gitignore ├── artifacts │ ├── ticket_ssm_war.xml │ └── ticket_ssm_war_exploded.xml ├── compiler.xml ├── encodings.xml ├── jarRepositories.xml ├── libraries │ ├── Maven__aopalliance_aopalliance_1_0.xml │ ├── Maven__com_alibaba_druid_1_0_18.xml │ ├── Maven__com_alibaba_fastjson_1_2_31.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_9.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_9_9.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_9_9.xml │ ├── Maven__com_github_kevinsawicki_http_request_5_6.xml │ ├── Maven__com_github_penggle_kaptcha_2_3_2.xml │ ├── Maven__com_google_inject_extensions_guice_multibindings_3_0.xml │ ├── Maven__com_google_inject_guice_3_0.xml │ ├── Maven__com_jhlabs_filters_2_0_235_1.xml │ ├── Maven__commons_beanutils_commons_beanutils_1_8_3.xml │ ├── Maven__commons_fileupload_commons_fileupload_1_3_3.xml │ ├── Maven__commons_io_commons_io_2_5.xml │ ├── Maven__commons_logging_commons_logging_1_2.xml │ ├── Maven__javax_inject_javax_inject_1.xml │ ├── Maven__javax_servlet_javax_servlet_api_3_0_1.xml │ ├── Maven__javax_servlet_jsp_jsp_api_2_1.xml │ ├── Maven__javax_servlet_jsp_jstl_jstl_api_1_2.xml │ ├── Maven__javax_servlet_jstl_1_2.xml │ ├── Maven__javax_servlet_servlet_api_2_5.xml │ ├── Maven__junit_junit_3_8_1.xml │ ├── Maven__log4j_log4j_1_2_16.xml │ ├── Maven__mysql_mysql_connector_java_5_1_34.xml │ ├── Maven__org_apache_commons_commons_lang3_3_4.xml │ ├── Maven__org_apache_shiro_shiro_all_1_2_4.xml │ ├── Maven__org_apache_shiro_shiro_core_1_2_4.xml │ ├── Maven__org_apache_shiro_shiro_guice_1_2_4.xml │ ├── Maven__org_aspectj_aspectjweaver_1_8_4.xml │ ├── Maven__org_mybatis_mybatis_3_4_5.xml │ ├── Maven__org_mybatis_mybatis_spring_1_3_2.xml │ ├── Maven__org_slf4j_slf4j_api_1_7_21.xml │ ├── Maven__org_slf4j_slf4j_log4j12_1_7_21.xml │ ├── Maven__org_springframework_spring_aop_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_beans_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_context_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_core_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_expression_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_jdbc_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_orm_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_test_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_tx_4_3_18_RELEASE.xml │ ├── Maven__org_springframework_spring_web_4_3_18_RELEASE.xml │ └── Maven__org_springframework_spring_webmvc_4_3_18_RELEASE.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── LICENSE ├── pom.xml ├── readme.md ├── src ├── main │ └── java │ │ └── com │ │ └── java │ │ └── ssm │ │ └── ticket │ │ ├── dao │ │ ├── AdminDao.java │ │ ├── OrderDao.java │ │ ├── ScenicDao.java │ │ └── UserDao.java │ │ ├── interceptor │ │ ├── AdminInterceptor.java │ │ └── UserInterceptor.java │ │ ├── model │ │ ├── Admin.java │ │ ├── Order.java │ │ ├── Scenic.java │ │ └── User.java │ │ ├── service │ │ ├── AdminService.java │ │ ├── OrderService.java │ │ ├── ScenicService.java │ │ └── UserService.java │ │ ├── utils │ │ └── DateUtil.java │ │ └── view │ │ ├── CaptchaController.java │ │ ├── IndexController.java │ │ ├── OrderController.java │ │ ├── ReserveConteroller.java │ │ ├── ScenicController.java │ │ ├── SearchConteroller.java │ │ ├── TestController.java │ │ ├── UserController.java │ │ └── admin │ │ └── AdminController.java └── test │ └── java │ └── test │ └── test.java └── ticket-ssm.iml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=java 2 | *.css linguist-language=java 3 | *.html linguist-language=java 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | .settings/ 13 | target/ 14 | 15 | #properties file 16 | # *.properties 17 | *.project 18 | .classpath 19 | 20 | # Package Files # 21 | *.jar 22 | *.war 23 | *.nar 24 | *.ear 25 | *.zip 26 | *.tar.gz 27 | *.rar 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | #使用Java的SSM技术栈开发一款在线景区售票系统 33 | /bin/ 34 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml 3 | -------------------------------------------------------------------------------- /.idea/artifacts/ticket_ssm_war.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target 4 | 5 | 6 | ticket-ssm 7 | war 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/artifacts/ticket_ssm_war_exploded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/target/ticket-ssm-0.0.1-SNAPSHOT 4 | 5 | 6 | true 7 | ticket-ssm 8 | war 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__aopalliance_aopalliance_1_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_alibaba_druid_1_0_18.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_alibaba_fastjson_1_2_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_github_kevinsawicki_http_request_5_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_github_penggle_kaptcha_2_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_inject_extensions_guice_multibindings_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_inject_guice_3_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_jhlabs_filters_2_0_235_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_beanutils_commons_beanutils_1_8_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_fileupload_commons_fileupload_1_3_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_io_commons_io_2_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_inject_javax_inject_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_javax_servlet_api_3_0_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_jsp_jsp_api_2_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_jsp_jstl_jstl_api_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_jstl_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_servlet_api_2_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__junit_junit_3_8_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__log4j_log4j_1_2_16.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__mysql_mysql_connector_java_5_1_34.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_all_1_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_core_1_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_shiro_shiro_guice_1_2_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_aspectj_aspectjweaver_1_8_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_3_4_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mybatis_mybatis_spring_1_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_21.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_7_21.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_aop_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_beans_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_core_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_expression_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_jdbc_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_orm_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_test_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_tx_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_web_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_18_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 \u4e01\u70c1 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.java.ssm.ticket 6 | ticket-ssm 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | 11 | 12 | org.apache.maven.plugins 13 | maven-compiler-plugin 14 | 15 | 1.8 16 | 1.8 17 | 18 | 19 | 20 | 38 | 39 | 40 | 41 | 42 | src/main/java 43 | 44 | 45 | **/*.xml 46 | 47 | 48 | 49 | src/main/resources 50 | 51 | **/*.xml 52 | 53 | **/*.properties 54 | **/mapper/** 55 | 56 | 57 | 58 | 59 | 60 | 61 | UTF-8 62 | 4.3.18.RELEASE 63 | 2.9.9 64 | 65 | 66 | 67 | junit 68 | junit 69 | 3.8.1 70 | test 71 | 72 | 73 | 74 | 75 | org.apache.shiro 76 | shiro-all 77 | 1.2.4 78 | 79 | 80 | 81 | 82 | org.springframework 83 | spring-core 84 | ${spring.version} 85 | 86 | 87 | org.springframework 88 | spring-beans 89 | ${spring.version} 90 | 91 | 92 | org.springframework 93 | spring-context 94 | ${spring.version} 95 | 96 | 97 | org.springframework 98 | spring-tx 99 | ${spring.version} 100 | 101 | 102 | org.springframework 103 | spring-web 104 | ${spring.version} 105 | 106 | 107 | org.springframework 108 | spring-test 109 | ${spring.version} 110 | test 111 | 112 | 113 | 114 | org.springframework 115 | spring-webmvc 116 | ${spring.version} 117 | 118 | 119 | 120 | org.springframework 121 | spring-orm 122 | ${spring.version} 123 | 124 | 125 | 126 | org.mybatis 127 | mybatis 128 | 3.4.5 129 | 130 | 131 | org.mybatis 132 | mybatis-spring 133 | 1.3.2 134 | 135 | 136 | 137 | 138 | 139 | org.slf4j 140 | slf4j-api 141 | 1.7.21 142 | 143 | 144 | org.slf4j 145 | slf4j-log4j12 146 | 1.7.21 147 | 148 | 149 | 150 | log4j 151 | log4j 152 | 1.2.16 153 | 154 | 155 | 156 | mysql 157 | mysql-connector-java 158 | 5.1.34 159 | 160 | 161 | 162 | 163 | com.alibaba 164 | druid 165 | 1.0.18 166 | 167 | 170 | 171 | com.fasterxml.jackson.core 172 | jackson-annotations 173 | ${jackson.version} 174 | 175 | 176 | com.fasterxml.jackson.core 177 | jackson-core 178 | ${jackson.version} 179 | 180 | 181 | com.fasterxml.jackson.core 182 | jackson-databind 183 | ${jackson.version} 184 | 185 | 186 | 187 | org.aspectj 188 | aspectjweaver 189 | 1.8.4 190 | 191 | 192 | 193 | 194 | javax.servlet 195 | javax.servlet-api 196 | 3.0.1 197 | provided 198 | 199 | 200 | 201 | javax.servlet 202 | jstl 203 | 1.2 204 | 205 | 206 | javax.servlet.jsp.jstl 207 | jstl-api 208 | 1.2 209 | 210 | 211 | 212 | 213 | com.alibaba 214 | fastjson 215 | 1.2.31 216 | 217 | 218 | 219 | commons-io 220 | commons-io 221 | 2.5 222 | 223 | 224 | org.apache.commons 225 | commons-lang3 226 | 3.4 227 | 228 | 229 | 230 | commons-fileupload 231 | commons-fileupload 232 | 1.3.3 233 | 234 | 235 | 236 | com.github.kevinsawicki 237 | http-request 238 | 5.6 239 | 240 | 246 | 247 | 248 | 249 | com.github.penggle 250 | kaptcha 251 | 2.3.2 252 | 253 | 254 | 255 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 基于SSM的景区(售票)管理系统 2 | 3 | ## 1、项目介绍 4 | 5 | 基于SSM的景区(售票)管理系统2拥有两个角色,分别为管理员和用户 6 | 7 | 管理员:订单管理、会员管理、景点管理 8 | 9 | 用户:景点查看、门票购买、订单查询等 10 | 11 | 12 | ## 2、项目技术 13 | 14 | 后端框架:SSM(Spring、SpringMVC、Mybatis 15 | 16 | 前端框架:Bootstrap、Layui、jsp、css、JavaScript、JQuery 17 | 18 | ## 3、开发环境 19 | 20 | - JAVA版本:JDK1.8,其它版本理论上可以 21 | - IDE类型:IDEA、Eclipse、Myeclipse都可以。推荐IDEA与Eclipse 22 | - tomcat版本:Tomcat 7.x、8.x、9.x、10.x版本均可 23 | - 数据库版本:MySql 5.x、8.x 24 | - maven版本:无限制 25 | - 硬件环境:Windows 或者 Mac OS 26 | 27 | 28 | ## 4、功能介绍 29 | 30 | ### 4.1 登录 31 | 32 | ![管理员-登录](https://www.codeshop.fun/Typora-Images/%E7%AE%A1%E7%90%86%E5%91%98-%E7%99%BB%E5%BD%95.jpg) 33 | 34 | ![用户-登录](https://www.codeshop.fun/Typora-Images/%E7%94%A8%E6%88%B7-%E7%99%BB%E5%BD%95.jpg) 35 | 36 | 上述分别为管理员和用户的登录界面 37 | 38 | ### 4.2用户 模块 39 | 40 | ![首页](https://www.codeshop.fun/Typora-Images/%E9%A6%96%E9%A1%B5.jpg) 41 | 42 | ![景点详情](https://www.codeshop.fun/Typora-Images/%E6%99%AF%E7%82%B9%E8%AF%A6%E6%83%85.jpg) 43 | 44 | ![用户-购买门票](https://www.codeshop.fun/Typora-Images/%E7%94%A8%E6%88%B7-%E8%B4%AD%E4%B9%B0%E9%97%A8%E7%A5%A8.jpg) 45 | 46 | ![用户-购买门票2](https://www.codeshop.fun/Typora-Images/%E7%94%A8%E6%88%B7-%E8%B4%AD%E4%B9%B0%E9%97%A8%E7%A5%A82.jpg) 47 | 48 | ![用户-订单记录](https://www.codeshop.fun/Typora-Images/%E7%94%A8%E6%88%B7-%E8%AE%A2%E5%8D%95%E8%AE%B0%E5%BD%95.jpg) 49 | 50 | 景点查看:用户可以首页浏览全部景点信息,还可以通过关键词模糊查询景点,也可以单独查看某个景点详情 51 | 52 | 门票购买:用户可以再预订门票界面输入人数,然后提交预订,即可成功购买门票 53 | 54 | 订单查询:用户可以查询浏览门票购买记录 55 | 56 | ### 4.3 管理员模块 57 | 58 | ![管理员-订单管理](https://www.codeshop.fun/Typora-Images/%E7%AE%A1%E7%90%86%E5%91%98-%E8%AE%A2%E5%8D%95%E7%AE%A1%E7%90%86.jpg) 59 | 60 | ![管理员-会员管理](https://www.codeshop.fun/Typora-Images/%E7%AE%A1%E7%90%86%E5%91%98-%E4%BC%9A%E5%91%98%E7%AE%A1%E7%90%86.jpg) 61 | 62 | ![管理员-景点管理](https://www.codeshop.fun/Typora-Images/%E7%AE%A1%E7%90%86%E5%91%98-%E6%99%AF%E7%82%B9%E7%AE%A1%E7%90%86.jpg) 63 | 64 | ![管理员-添加景点](https://www.codeshop.fun/Typora-Images/%E7%AE%A1%E7%90%86%E5%91%98-%E6%B7%BB%E5%8A%A0%E6%99%AF%E7%82%B9.jpg) 65 | 66 | 订单管理:管理员可以查看订单详情、删除订单信息 67 | 68 | 会员管理:管理员可以修改和删除用户 69 | 70 | 景点管理:管理员可以查看、增加、删除景点信息 71 | 72 | 73 | 74 | ## 6、获取方式 75 | 76 | 关注公众号: **程序员王不二**,回复 “ **景点2**” ,即可获取完整版的项目代码。 77 | 78 | ![](https://www.codeshop.fun/Typora-Images/202205281253739.png) 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/dao/AdminDao.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.dao; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Select; 5 | 6 | import com.java.ssm.ticket.model.Admin; 7 | 8 | /** 9 | * 管理员数据层 10 | */ 11 | @Mapper 12 | public interface AdminDao { 13 | 14 | /** 15 | * 查询管理员 16 | * @param id 17 | * @return 管理员 18 | */ 19 | @Select("SELECT * FROM `admin_table` WHERE id = #{id}") 20 | Admin findAdminById(Integer id); 21 | 22 | /** 23 | * 查询管理员 24 | * @param username 25 | * @return 管理员 26 | */ 27 | @Select("SELECT * FROM `admin_table` WHERE username = #{username}") 28 | Admin findAdminByUsername(String username); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/dao/OrderDao.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Options; 9 | import org.apache.ibatis.annotations.Param; 10 | import org.apache.ibatis.annotations.Select; 11 | import org.apache.ibatis.annotations.Update; 12 | 13 | import com.java.ssm.ticket.model.Order; 14 | 15 | /** 16 | * 订单服务层 17 | * 18 | */ 19 | @Mapper 20 | public interface OrderDao { 21 | 22 | @Select("SELECT * FROM `ticket`.`order_table` WHERE oid = #{oid}") 23 | Order findOrderByOid(long oid); 24 | 25 | @Options(useGeneratedKeys = true, keyProperty = "oid") 26 | @Insert("INSERT INTO `ticket`.`order_table`(`order_number`,`create_time`, `order_uid`, `total_money`, `scenic_name`,`people_number`) VALUES (#{orderNumber}, #{createTime}, #{orderUid},#{totalMoney},#{scenicName},#{peopleNumber})") 27 | int saveOrder(Order order); 28 | 29 | @Update("UPDATE `ticket`.`order_table` SET order_number = #{orderNumber},create_time = #{createTime},order_uid = #{orderUid},total_money = #{totalMoney},scenic_name = #{scenicName},people_number = #{peopleNumber} WHERE oid = #{oid}") 30 | int UpdateOrder(Order order); 31 | 32 | @Select("SELECT * FROM `ticket`.`order_table`") 33 | List getAllOrder(); 34 | 35 | @Select("SELECT * FROM `ticket`.`order_table` WHERE order_uid = #{uid}") 36 | List findOrderByUid(@Param("uid") long uid); 37 | 38 | @Delete("DELETE FROM `ticket`.`order_table` WHERE oid = #{oid}") 39 | int delOrderByOid(long oid); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/dao/ScenicDao.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Options; 9 | import org.apache.ibatis.annotations.Param; 10 | import org.apache.ibatis.annotations.Select; 11 | import org.apache.ibatis.annotations.Update; 12 | 13 | import com.java.ssm.ticket.model.Scenic; 14 | 15 | /** 16 | * 景点数据访问接口 17 | */ 18 | @Mapper 19 | public interface ScenicDao { 20 | 21 | /** 22 | * 通过sid查询 23 | * 24 | * @param sid 25 | * @return scenic 26 | */ 27 | @Select("SELECT * FROM `ticket`.`scenic_table` WHERE sid = #{sid}") 28 | Scenic findScenicBySid(long sid); 29 | 30 | /** 31 | * 保持Scenic 32 | * 33 | * @param scenic 34 | * @return int > 0 插入成功 35 | */ 36 | @Options(useGeneratedKeys = true, keyProperty = "sid") 37 | @Insert("INSERT INTO `ticket`.`scenic_table`(`scenic_name`, `scenic_price`, `scenic_address`, `scenic_details`, `scenic_pic`, `scenic_star`, `createTime`) VALUES (#{scenicName}, #{scenicPrice}, #{scenicAddress},#{scenicDetails}, #{scenicPic}, #{scenicStar}, #{createTime})") 38 | int saveScenic(Scenic scenic); 39 | 40 | /** 41 | * 更新Scenic 42 | * 43 | * @param scenic 44 | * @return int > 0 更新成功 45 | */ 46 | @Update("UPDATE scenic_table SET scenic_name = #{scenicName},scenic_price = #{scenicPrice},scenic_address = #{scenicAddress},scenic_details = #{scenicDetails},scenic_pic = #{scenicPic},scenic_star = #{scenicStar},createTime = #{createTime} WHERE sid = #{sid}") 47 | int UpdateScenic(Scenic scenic); 48 | 49 | /** 50 | * 获取全部的Scenic 51 | * 52 | * @return 集合scenic 53 | */ 54 | @Select("SELECT * FROM `ticket`.`scenic_table`") 55 | List getAllScenic(); 56 | 57 | /** 58 | * 模糊查询 PS:注意是模糊查询在mybatis里面的key参数表示为 ${Key} 59 | * 问题详情:https://www.cnblogs.com/hcl763088301/p/11228878.html 60 | * 通过@Param 注解绑定参数 61 | * @param Key 关键字 62 | * @return 查询结果集合 63 | */ 64 | @Select("SELECT * FROM `scenic_table` WHERE scenic_name LIKE '%${Key}%'") 65 | List searchKeyScenic(@Param("Key") String Key); 66 | 67 | @Delete("DELETE FROM `ticket`.`scenic_table` WHERE sid = #{sid}") 68 | int deleteScenicById(long sid); 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Options; 9 | import org.apache.ibatis.annotations.Param; 10 | import org.apache.ibatis.annotations.Select; 11 | import org.apache.ibatis.annotations.Update; 12 | 13 | import com.java.ssm.ticket.model.User; 14 | 15 | /** 16 | * 用户数据访问 17 | * @author hgy 18 | */ 19 | @Mapper 20 | public interface UserDao { 21 | 22 | /** 23 | * 通过id查询用户 24 | * @param uid 25 | * @return User 26 | */ 27 | @Select("SELECT * FROM `ticket`.`user_table` WHERE uid = #{uid}") 28 | User findUserById(long uid); 29 | 30 | 31 | @Select("SELECT * FROM `ticket`.`user_table`") 32 | List allUsers(); 33 | 34 | /** 35 | * 保存用户 useGeneratedKeys设置uid自增 36 | * @param user 37 | * @return int 1代表插入成功 38 | */ 39 | @Options(useGeneratedKeys = true, keyProperty = "uid") 40 | @Insert("INSERT INTO `ticket`.`user_table`(username,password,createTime,idcard) VALUES (#{username},#{password},#{createTime},#{idcard})") 41 | int saveUser(User user); 42 | 43 | 44 | @Update("UPDATE `ticket`.`user_table` SET username = #{username},password = #{password},createTime = #{createTime},idcard = #{idcard} WHERE uid = #{uid}") 45 | int UpdateUser(User u); 46 | 47 | /** 48 | * 通过idcard 身份证号查询 @Param绑定查询参数 49 | * @param idcard 50 | * @return user 51 | */ 52 | @Select("SELECT * FROM `ticket`.`user_table` WHERE idcard = #{idcard}") 53 | User findUserByIdCard(@Param(value = "idcard") String idcard); 54 | 55 | @Delete("DELETE FROM `ticket`.`user_table` WHERE uid = #{uid}") 56 | int delOneUser(long uid); 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/interceptor/AdminInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.HandlerInterceptor; 8 | import org.springframework.web.servlet.ModelAndView; 9 | 10 | 11 | public class AdminInterceptor implements HandlerInterceptor { 12 | 13 | @Override 14 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 15 | throws Exception { 16 | HttpSession session = request.getSession(); 17 | //如果session里面有用户说明登录成功 18 | if (session.getAttribute("LOGIN_ADMIN") != null) { 19 | // 登录成功不拦截 20 | return true; 21 | } else { 22 | // 登录失败 23 | // 拦截后进入登录页面 24 | String path = request.getContextPath(); 25 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 26 | + path; 27 | response.sendRedirect(basePath + "/admin/login"); 28 | return false; 29 | } 30 | 31 | } 32 | 33 | @Override 34 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, 35 | ModelAndView modelAndView) throws Exception { 36 | // TODO Auto-generated method stub 37 | 38 | } 39 | 40 | @Override 41 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) 42 | throws Exception { 43 | // TODO Auto-generated method stub 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/interceptor/UserInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.interceptor; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | import javax.servlet.http.HttpSession; 6 | 7 | import org.springframework.web.servlet.HandlerInterceptor; 8 | import org.springframework.web.servlet.ModelAndView; 9 | 10 | import com.java.ssm.ticket.view.UserController; 11 | /** 12 | * 用户拦截器 13 | */ 14 | public class UserInterceptor implements HandlerInterceptor { 15 | 16 | /** 17 | * 检查用户是否登录拦截器 18 | */ 19 | @Override 20 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 21 | throws Exception { 22 | 23 | HttpSession session = request.getSession(); 24 | //如果session里面有用户说明登录成功 25 | if (session.getAttribute(UserController.USER_LOGIN_KEY) != null) { 26 | // 登录成功不拦截 27 | return true; 28 | } else { 29 | // 登录失败 30 | // 拦截后进入登录页面 31 | String path = request.getContextPath(); 32 | String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() 33 | + path; 34 | response.sendRedirect(basePath + "/login"); 35 | return false; 36 | } 37 | 38 | } 39 | 40 | @Override 41 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, 42 | ModelAndView modelAndView) throws Exception { 43 | // TODO Auto-generated method stub 44 | 45 | } 46 | 47 | @Override 48 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) 49 | throws Exception { 50 | // TODO Auto-generated method stub 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/model/Admin.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.model; 2 | 3 | /** 4 | * 管理员实体 5 | */ 6 | public class Admin { 7 | private Integer id; 8 | private String username; 9 | private String password; 10 | 11 | @Override 12 | public String toString() { 13 | return "Admin [id=" + id + ", username=" + username + ", password=" + password + "]"; 14 | } 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public String getUsername() { 25 | return username; 26 | } 27 | 28 | public void setUsername(String username) { 29 | this.username = username; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/model/Order.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.model; 2 | 3 | import java.math.BigDecimal; 4 | import java.sql.Timestamp; 5 | 6 | /** 7 | * 订单实体 8 | */ 9 | public class Order { 10 | 11 | private long oid; 12 | private String orderNumber; 13 | private Timestamp createTime; 14 | private long orderUid; 15 | private BigDecimal totalMoney; 16 | private String scenicName; 17 | private Integer peopleNumber; 18 | 19 | public long getOid() { 20 | return oid; 21 | } 22 | 23 | public void setOid(long oid) { 24 | this.oid = oid; 25 | } 26 | 27 | public String getOrderNumber() { 28 | return orderNumber; 29 | } 30 | 31 | public void setOrderNumber(String orderNumber) { 32 | this.orderNumber = orderNumber; 33 | } 34 | 35 | public Timestamp getCreateTime() { 36 | return createTime; 37 | } 38 | 39 | public void setCreateTime(Timestamp createTime) { 40 | this.createTime = createTime; 41 | } 42 | 43 | public long getOrderUid() { 44 | return orderUid; 45 | } 46 | 47 | public void setOrderUid(long orderUid) { 48 | this.orderUid = orderUid; 49 | } 50 | 51 | public BigDecimal getTotalMoney() { 52 | return totalMoney; 53 | } 54 | 55 | public void setTotalMoney(BigDecimal totalMoney) { 56 | this.totalMoney = totalMoney; 57 | } 58 | 59 | public String getScenicName() { 60 | return scenicName; 61 | } 62 | 63 | public void setScenicName(String scenicName) { 64 | this.scenicName = scenicName; 65 | } 66 | 67 | public Integer getPeopleNumber() { 68 | return peopleNumber; 69 | } 70 | 71 | public void setPeopleNumber(Integer peopleNumber) { 72 | this.peopleNumber = peopleNumber; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "Order [oid=" + oid + ", orderNumber=" + orderNumber + ", createTime=" + createTime + ", orderUid=" 78 | + orderUid + ", totalMoney=" + totalMoney + ", scenicName=" + scenicName + ", peopleNumber=" 79 | + peopleNumber + "]"; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/model/Scenic.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.model; 2 | 3 | import java.math.BigDecimal; 4 | import java.sql.Timestamp; 5 | 6 | /** 7 | * 景点表对应的实体类 8 | */ 9 | public class Scenic { 10 | private long sid; 11 | private String scenicName; 12 | private BigDecimal scenicPrice; 13 | private String scenicAddress; 14 | private String scenicDetails; 15 | private String scenicPic; 16 | private Integer scenicStar; 17 | private Timestamp createTime; 18 | 19 | public long getSid() { 20 | return sid; 21 | } 22 | 23 | public void setSid(long sid) { 24 | this.sid = sid; 25 | } 26 | 27 | public String getScenicName() { 28 | return scenicName; 29 | } 30 | 31 | public void setScenicName(String scenicName) { 32 | this.scenicName = scenicName; 33 | } 34 | 35 | public BigDecimal getScenicPrice() { 36 | return scenicPrice; 37 | } 38 | 39 | public void setScenicPrice(BigDecimal scenicPrice) { 40 | this.scenicPrice = scenicPrice; 41 | } 42 | 43 | public String getScenicAddress() { 44 | return scenicAddress; 45 | } 46 | 47 | public void setScenicAddress(String scenicAddress) { 48 | this.scenicAddress = scenicAddress; 49 | } 50 | 51 | public String getScenicDetails() { 52 | return scenicDetails; 53 | } 54 | 55 | public void setScenicDetails(String scenicDetails) { 56 | this.scenicDetails = scenicDetails; 57 | } 58 | 59 | public String getScenicPic() { 60 | return scenicPic; 61 | } 62 | 63 | public void setScenicPic(String scenicPic) { 64 | this.scenicPic = scenicPic; 65 | } 66 | 67 | public Integer getScenicStar() { 68 | return scenicStar; 69 | } 70 | 71 | public void setScenicStar(Integer scenicStar) { 72 | this.scenicStar = scenicStar; 73 | } 74 | 75 | public Timestamp getCreateTime() { 76 | return createTime; 77 | } 78 | 79 | public void setCreateTime(Timestamp createTime) { 80 | this.createTime = createTime; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return "Scenic [sid=" + sid + ", scenicName=" + scenicName + ", scenicPrice=" + scenicPrice + ", scenicAddress=" 86 | + scenicAddress + ", scenicDetdils=" + scenicDetails + ", scenicPic=" + scenicPic + ", scenicStar=" 87 | + scenicStar + ", createTime=" + createTime + "]"; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/model/User.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.model; 2 | 3 | import java.sql.Timestamp; 4 | 5 | //对应用户表 6 | public class User { 7 | 8 | private long uid; 9 | private String username; 10 | private String password; 11 | private Timestamp createTime; 12 | private String idcard; 13 | 14 | public long getUid() { 15 | return uid; 16 | } 17 | 18 | public void setUid(long uid) { 19 | this.uid = uid; 20 | } 21 | 22 | public String getUsername() { 23 | return username; 24 | } 25 | 26 | public void setUsername(String username) { 27 | this.username = username; 28 | } 29 | 30 | public String getPassword() { 31 | return password; 32 | } 33 | 34 | public void setPassword(String password) { 35 | this.password = password; 36 | } 37 | 38 | public Timestamp getCreateTime() { 39 | return createTime; 40 | } 41 | 42 | public void setCreateTime(Timestamp createTime) { 43 | this.createTime = createTime; 44 | } 45 | 46 | public String getIdcard() { 47 | return idcard; 48 | } 49 | 50 | public void setIdcard(String idcard) { 51 | this.idcard = idcard; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "User [uid=" + uid + ", username=" + username + ", password=" + password + ", createTime=" + createTime 57 | + ", idcard=" + idcard + "]"; 58 | } 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/service/AdminService.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.service; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.java.ssm.ticket.dao.AdminDao; 9 | import com.java.ssm.ticket.model.Admin; 10 | 11 | /** 12 | * admin服务层 13 | */ 14 | @Component 15 | public class AdminService { 16 | 17 | @Autowired 18 | AdminDao ad; 19 | 20 | @Autowired 21 | HttpServletRequest request; 22 | 23 | /** 24 | * 登录管理员 25 | * 26 | * @param admin 27 | * @return true账号和密码正确 28 | */ 29 | public Boolean checkAdmin(Admin admin) { 30 | // 通过管理员账号查询用户 31 | Admin ainfo = ad.findAdminByUsername(admin.getUsername()); 32 | // 如果表单的密码和数据库通过管理员账号查询带密码一致就表明账号和密码正确 33 | if (admin.getPassword().equals(ainfo.getPassword())) { 34 | request.getSession().setAttribute("LOGIN_ADMIN", ainfo); 35 | return true; 36 | } 37 | return false; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.service; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import com.java.ssm.ticket.dao.OrderDao; 13 | import com.java.ssm.ticket.dao.ScenicDao; 14 | import com.java.ssm.ticket.model.Order; 15 | import com.java.ssm.ticket.model.Scenic; 16 | import com.java.ssm.ticket.model.User; 17 | import com.java.ssm.ticket.utils.DateUtil; 18 | import com.java.ssm.ticket.view.UserController; 19 | 20 | /** 21 | * 订单业务 22 | */ 23 | @Component 24 | public class OrderService { 25 | 26 | @Autowired 27 | OrderDao od; 28 | 29 | @Autowired 30 | ScenicDao sd; 31 | 32 | @Autowired 33 | HttpServletRequest req; 34 | 35 | /** 36 | * 下单业务 37 | */ 38 | public Boolean putReserveOrder(String sid, String count) { 39 | // 获取session中的用户id 40 | User ur = (User) req.getSession().getAttribute(UserController.USER_LOGIN_KEY); 41 | // 生成订单id 42 | String orderNumber = UUID.randomUUID().toString(); 43 | // 通过景点id查询景点信息 44 | Scenic sc = sd.findScenicBySid(Long.valueOf(sid)); 45 | //创建order实体存储到数据库 46 | Order or = new Order(); 47 | or.setOrderUid(ur.getUid()); 48 | or.setOrderNumber(orderNumber); 49 | or.setPeopleNumber(Integer.valueOf(count)); 50 | or.setCreateTime(DateUtil.asDateToTimestamp()); 51 | or.setScenicName(sc.getScenicName()); 52 | or.setTotalMoney(totalPrice(sc.getScenicPrice(), Integer.valueOf(count))); 53 | return !(od.saveOrder(or) > 1); 54 | } 55 | /** 56 | * 57 | * @param uid 用户id 58 | * @return 返回用户订单记录列表 59 | */ 60 | public List asUserOfOrderList(){ 61 | // 获取session中的用户id 62 | User ur = (User) req.getSession().getAttribute(UserController.USER_LOGIN_KEY); 63 | return od.findOrderByUid(ur.getUid()); 64 | } 65 | 66 | public List allOrders(){ 67 | return od.getAllOrder(); 68 | } 69 | 70 | public boolean delOneOrder(String oid) { 71 | return (od.delOrderByOid(Long.valueOf(oid))>0); 72 | } 73 | 74 | // 计算总价 75 | public BigDecimal totalPrice(BigDecimal price, Integer count) { 76 | return price.multiply(BigDecimal.valueOf(count)); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/service/ScenicService.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.java.ssm.ticket.dao.ScenicDao; 9 | import com.java.ssm.ticket.model.Scenic; 10 | 11 | /** 12 | * scenic服务业务层 13 | */ 14 | @Component 15 | public class ScenicService { 16 | 17 | 18 | @Autowired 19 | ScenicDao sd; 20 | 21 | /** 22 | * 获取所有scenic信息 23 | * @return 集合scenic 24 | */ 25 | public List getAll(){ 26 | return sd.getAllScenic(); 27 | } 28 | 29 | /** 30 | * 获取通过sid获取scenic 31 | * @param sid 32 | * @return scenic 33 | */ 34 | public Scenic getScenicBySid(String sid) { 35 | return sd.findScenicBySid(Long.valueOf(sid)); 36 | } 37 | 38 | 39 | public Boolean deleteScenicById(String sid) { 40 | return (sd.deleteScenicById(Long.valueOf(sid)) >0 ); 41 | } 42 | 43 | public Boolean saveScenic(Scenic sc) { 44 | return (sd.saveScenic(sc) > 0); 45 | } 46 | 47 | /** 48 | * star热门次数自加 49 | * @param sid 50 | */ 51 | public void addOneStar(String sid){ 52 | Scenic sc = sd.findScenicBySid(Long.valueOf(sid)); 53 | //获取数据库原理的值然后加1 然后就实现用户每点击一次详情 景点star数就加一 54 | sc.setScenicStar(sc.getScenicStar()+1); 55 | //更新保存到数据库 56 | sd.UpdateScenic(sc); 57 | } 58 | 59 | /** 60 | * 通过关键字查询景点 61 | * @param key 关键字 62 | * @return 返回查询结果集合 63 | */ 64 | public List searchKey(String key){ 65 | //调用数据访问层 66 | return sd.searchKeyScenic(key); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.java.ssm.ticket.dao.UserDao; 9 | import com.java.ssm.ticket.model.User; 10 | 11 | 12 | /** 13 | * 用户服务业务层 Component 标明这是一个Service 14 | */ 15 | @Component 16 | public class UserService { 17 | 18 | @Autowired 19 | UserDao userDao; 20 | 21 | 22 | /** 23 | * 注册用户 24 | * @param user 25 | * @return true 新插入用户成功 26 | */ 27 | public Boolean registerOneUserInfo(User user) { 28 | return userDao.saveUser(user) > 0 ? true : false; 29 | } 30 | /** 31 | * 查询用户是否被注册 32 | * @param idcard 33 | * @return false 身份证已经被注册 34 | */ 35 | public Boolean checkUserIdCard(String idcard) { 36 | return userDao.findUserByIdCard(idcard) != null ? false : true; 37 | } 38 | 39 | /** 40 | * 检查用户账号和密码是否正确 41 | * @param user 42 | * @return true 表示正确 43 | */ 44 | public Boolean checkUserPassword(User user) { 45 | //通过身份证查询用户 46 | User u =userDao.findUserByIdCard(user.getIdcard()); 47 | //如果表单的密码和数据库通过身份证id查询带密码一致就表明账号和密码正确 48 | if(user.getPassword().equals(u.getPassword())) { 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | /** 55 | * 通过身份证查询用户 56 | * @param idcard 57 | * @return 用户 58 | */ 59 | public User getUserByIdCard(String idcard){ 60 | return userDao.findUserByIdCard(idcard); 61 | } 62 | 63 | 64 | public Boolean updateUser(User user) { 65 | return (userDao.UpdateUser(user)>0); 66 | } 67 | 68 | public User getUserByUid(String id){ 69 | return userDao.findUserById(Long.valueOf(id)); 70 | } 71 | 72 | public List getAllUsers(){ 73 | return userDao.allUsers(); 74 | } 75 | 76 | public boolean delUserByUid(String uid) { 77 | return (userDao.delOneUser(Long.valueOf(uid)) > 0); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/utils/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.sql.Timestamp; 6 | import java.text.ParseException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Calendar; 9 | import java.util.Date; 10 | import java.util.TimeZone; 11 | 12 | 13 | 14 | //hgy 自己在网上找来的工具类 15 | 16 | 17 | /** 18 | * @ Author: Ding
19 | * @ Version: V1.0 20 | * @ Notes: 时间工具类 21 | *

22 | * Created with IDEA. Date:2019/11/22 8:46 下午 23 | * Github Home Page 24 | *

25 | */ 26 | public class DateUtil { 27 | public static final String FMT_YM = "yyyyMM"; 28 | public static final String FMT_Y_M = "yyyy-MM"; 29 | 30 | public static final String FMT_YMD = "yyyyMMdd"; 31 | public static final String FMT_Y_M_D = "yyyy-MM-dd"; 32 | 33 | public static final String FMT_YMD_HMS = "yyyyMMddHHmmss"; 34 | public static final String FMT_Y_M_D_H_M_S = "yyyy-MM-dd HH:mm:ss"; 35 | public static final String FMT_UTC_Y_M_D_H_M_S = "yyyy-MM-dd'T'HH:mm:ss"; 36 | public static final String FMT_UTC_Y_M_D_H_M_S_Z = "yyyy-MM-dd'T'HH:mm:ss'Z'"; 37 | 38 | public static final String FMT_YMD_HMS_S = "yyyyMMddHHmmssSSS"; 39 | public static final String FMT_Y_M_D_H_M_S_S = "yyyy-MM-dd HH:mm:ss.SSS"; 40 | 41 | 42 | public static final String FMT_HMS = "HHmmss"; 43 | public static final String FMT_H_M_S = "HH:mm:ss"; 44 | 45 | public static final String FMT_HMS_S = "HHmmssSSS"; 46 | public static final String FMT_H_M_S_S = "HH:mm:ss.SSS"; 47 | 48 | public static final String FMT_CHINESE_Y_M_D = "yyyy年MM月dd日"; 49 | public static final String FMT_CHINESE_Y_M_D_H_M_S = "yyyy年MM月dd日 HH:mm:ss"; 50 | public static final String FMT_CHINESE_Y_M_D_H_M_S_S = "yyyy年MM月dd日 HH:mm:ss.SSS"; 51 | 52 | public static final String FMT_DEFAULT = "yyyy-MM-dd HH:mm:ss"; 53 | private DateUtil dateUtil; 54 | 55 | public enum Field { 56 | YEAR, 57 | MONTH, 58 | WEEK, 59 | DAY, 60 | HOUR, // 24小时制 61 | MINUTE, 62 | SECOND, 63 | MILLISECOND 64 | } 65 | 66 | /** 67 | * date转日期字符串 68 | * 69 | * @param date 70 | * @param format 71 | * @return String 72 | */ 73 | public static String str(Date date, String format) { 74 | if (null == date) { 75 | date = new Date(); 76 | } 77 | if (StringUtils.isBlank(format)) { 78 | format = FMT_DEFAULT; 79 | } 80 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); 81 | simpleDateFormat.setLenient(false); 82 | return simpleDateFormat.format(date); 83 | } 84 | 85 | /** 86 | * time转日期字符串 87 | * 88 | * @param time 89 | * @param format 90 | * @return String 91 | */ 92 | public static String str(long time, String format) { 93 | return str(new Date(time), format); 94 | } 95 | 96 | /** 97 | * 字符串转日期 98 | * 99 | * @param dateStr 100 | * @param format 101 | * @return Date 102 | */ 103 | public static Date date(String dateStr, String format) throws ParseException { 104 | if (StringUtils.isBlank(dateStr)) { 105 | return null; 106 | } 107 | if (StringUtils.isBlank(format)) { 108 | format = FMT_DEFAULT; 109 | } 110 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); 111 | simpleDateFormat.setLenient(false); 112 | return simpleDateFormat.parse(dateStr); 113 | } 114 | 115 | /** 116 | * 字符串日期转time 117 | * 118 | * @param dateStr 119 | * @param format 120 | * @return String 121 | */ 122 | public static long time(String dateStr, String format) throws ParseException { 123 | Date date = date(dateStr, format); 124 | if (null == date) { 125 | return 0L; 126 | } 127 | return date.getTime(); 128 | } 129 | 130 | /** 131 | * 获取UTC标准时间(北京时区时间-8小时) 132 | * Demo: 2018-11-01 09:35:00转换后为2018-11-01T01:35:00 133 | * 134 | * @param date 135 | */ 136 | public static String utc(Date date) { 137 | if (null == date) { 138 | date = new Date(); 139 | } 140 | SimpleDateFormat df = new SimpleDateFormat(FMT_UTC_Y_M_D_H_M_S); 141 | df.setTimeZone(TimeZone.getTimeZone("UTC")); 142 | return df.format(date); 143 | } 144 | 145 | /** 146 | * 获取UTC标准时间(北京时区时间-8小时) 147 | * Demo: 2018-11-01 09:35:00转换后为2018-11-01T01:35:00 148 | * 149 | * @param dateStr 150 | * @param format 151 | */ 152 | public static String utc(String dateStr, String format) throws ParseException { 153 | Date date = date(dateStr, format); 154 | if (null == date) { 155 | date = new Date(); 156 | } 157 | return utc(date); 158 | } 159 | 160 | /** 161 | * 日期加减操作 162 | * 163 | * @param date 164 | * @param field 165 | * @param value 166 | * @return Date 167 | */ 168 | public static Date add(Date date, Field field, int value) { 169 | if (null == date) { 170 | date = new Date(); 171 | } 172 | Calendar calendar = Calendar.getInstance(); 173 | calendar.setTime(date); 174 | int calendarField = fieldParse(field); 175 | calendar.set(calendarField, calendar.get(calendarField) + value); 176 | return calendar.getTime(); 177 | } 178 | 179 | /** 180 | * 字符串日期加减操作 181 | * 182 | * @param dateStr 183 | * @param format 184 | * @param field 185 | * @param value 186 | * @return String 187 | */ 188 | public static String add(String dateStr, String format, Field field, int value) throws ParseException { 189 | if (StringUtils.isBlank(dateStr)) { 190 | return null; 191 | } 192 | if (StringUtils.isBlank(format)) { 193 | format = FMT_DEFAULT; 194 | } 195 | Date date = date(dateStr, format); 196 | return str(add(date, field, value), format); 197 | } 198 | 199 | /** 200 | * 日期Field设置操作 201 | * 202 | * @param date 203 | * @param field 204 | * @param value 205 | * @return String 206 | */ 207 | public static Date set(Date date, Field field, int value) { 208 | if (null == date) { 209 | date = new Date(); 210 | } 211 | Calendar calendar = Calendar.getInstance(); 212 | calendar.setTime(date); 213 | calendar.set(fieldParse(field), value); 214 | return calendar.getTime(); 215 | } 216 | 217 | /** 218 | * 日期Field设置操作 219 | * 220 | * @param date 221 | * @param fields 222 | * @param values 223 | * @return String 224 | */ 225 | public static Date set(Date date, Field[] fields, int[] values) { 226 | if (null == date) { 227 | date = new Date(); 228 | } 229 | Calendar calendar = Calendar.getInstance(); 230 | calendar.setTime(date); 231 | if (null != fields && fields.length > 0) { 232 | for (int i = 0; i < fields.length; ++i) { 233 | calendar.set(fieldParse(fields[i]), values[i]); 234 | } 235 | } 236 | return calendar.getTime(); 237 | } 238 | 239 | /** 240 | * 日期域set操作,返回set后的日期字符串 241 | * 242 | * @param dateStr 243 | * @param format 244 | * @param field 245 | * @param value 246 | * @return String 247 | */ 248 | public static String set(String dateStr, String format, Field field, int value) throws ParseException { 249 | if (StringUtils.isBlank(dateStr)) { 250 | return null; 251 | } 252 | if (StringUtils.isBlank(format)) { 253 | format = FMT_DEFAULT; 254 | } 255 | Date date = date(dateStr, format); 256 | return str(set(date, field, value), format); 257 | } 258 | 259 | /** 260 | * 日期域set操作,返回set后的日期字符串 261 | * 262 | * @param dateStr 263 | * @param format 264 | * @param fields 265 | * @param values 266 | * @return String 267 | */ 268 | public static String set(String dateStr, String format, Field[] fields, int[] values) throws ParseException { 269 | if (StringUtils.isBlank(dateStr)) { 270 | return null; 271 | } 272 | if (StringUtils.isBlank(format)) { 273 | format = FMT_DEFAULT; 274 | } 275 | Date date = date(dateStr, format); 276 | return str(set(date, fields, values), format); 277 | } 278 | 279 | /** 280 | * 日期间隔差,返回指定域的时间差绝对值 281 | * 注意:这里是做转换成Time后的值比较,不是按域比较。如: 282 | * 1. 小于24小时,日、周、月、年值为0 283 | * 2. 大于等于24小时,小于48小时,日值为1,周、月、年值为0 284 | * 285 | * @param date1 286 | * @param date2 287 | * @param field 288 | * @return int 289 | */ 290 | public static long between(Date date1, Date date2, Field field) { 291 | if (null == date1 && null == date2) { 292 | return 0; 293 | } 294 | if (null == date1) { 295 | date1 = new Date(); 296 | } 297 | if (null == date2) { 298 | date2 = new Date(); 299 | } 300 | long millSeconds = Math.abs(date1.getTime() - date2.getTime()); 301 | switch (field) { 302 | case SECOND: 303 | return millSeconds / 1000; 304 | case MINUTE: 305 | return millSeconds / 1000 / 60; 306 | case HOUR: 307 | return millSeconds / 1000 / 3600; 308 | case DAY: 309 | return millSeconds / 1000 / 3600 / 24; 310 | case WEEK: 311 | return millSeconds / 1000 / 3600 / 24 / 7; 312 | case MONTH: 313 | return millSeconds / 1000 / 3600 / 24 / 30; 314 | case YEAR: 315 | return millSeconds / 1000 / 3600 / 24 / 365; 316 | } 317 | return millSeconds; 318 | } 319 | 320 | /** 321 | * 字符串日期间隔差,返回指定域的时间差绝对值 322 | * 323 | * @param dateStr1 324 | * @param dateStr2 325 | * @param field 326 | * @return int 327 | */ 328 | public static long between(String dateStr1, String dateStr2, String format, Field field) throws ParseException { 329 | if (StringUtils.isBlank(dateStr1) && StringUtils.isBlank(dateStr2)) { 330 | return 0; 331 | } 332 | if (StringUtils.isBlank(format)) { 333 | format = FMT_DEFAULT; 334 | } 335 | Date date1 = date(dateStr1, format); 336 | Date date2 = date(dateStr2, format); 337 | return between(date1, date2, field); 338 | } 339 | 340 | /** 341 | * 日期对比 342 | * 343 | * @param date1 344 | * @param date2 345 | * @return long 346 | */ 347 | public static long compare(Date date1, Date date2) { 348 | if (null == date1 && null == date2) { 349 | return 0; 350 | } 351 | if (null == date1) { 352 | date1 = new Date(); 353 | } 354 | if (null == date2) { 355 | date2 = new Date(); 356 | } 357 | return date1.getTime() - date2.getTime(); 358 | } 359 | 360 | /** 361 | * 返回当前日期所在月有多少天 362 | * 363 | * @param date 364 | * @return int 365 | */ 366 | public static int daysOfMonth(Date date) { 367 | if (null == date) { 368 | date = new Date(); 369 | } 370 | Calendar calendar = Calendar.getInstance(); 371 | calendar.setTime(date); 372 | calendar.set(Calendar.DAY_OF_MONTH, 1); 373 | calendar.roll(Calendar.DAY_OF_MONTH, -1); 374 | return calendar.get(Calendar.DAY_OF_MONTH); 375 | } 376 | 377 | /** 378 | * 返回当前日期所在年有多少天 379 | * 380 | * @param date 381 | * @return int 382 | */ 383 | public static int daysOfYear(Date date) { 384 | if (null == date) { 385 | date = new Date(); 386 | } 387 | Calendar calendar = Calendar.getInstance(); 388 | calendar.setTime(date); 389 | calendar.set(Calendar.DAY_OF_YEAR, 1); 390 | calendar.roll(Calendar.DAY_OF_YEAR, -1); 391 | return calendar.get(Calendar.DAY_OF_YEAR); 392 | } 393 | 394 | /** 395 | * 获取日期所在月第一天 396 | * 397 | * @param date 398 | * @param time 自定义时间(默认00:00:00) 399 | * @return Date 400 | */ 401 | public static Date firstDayOfMonth(Date date, String time) { 402 | if (null == date) { 403 | date = new Date(); 404 | } 405 | if (StringUtils.isBlank(time)) { 406 | time = "000000"; 407 | } 408 | return getDate(date, time); 409 | } 410 | 411 | /** 412 | * 获取日期所在月最后一天 413 | * 414 | * @param date 415 | * @param time 自定义时间(默认23:59:59) 416 | * @return Date 417 | */ 418 | public static Date lastDayOfMonth(Date date, String time) { 419 | if (null == date) { 420 | date = new Date(); 421 | } 422 | if (StringUtils.isBlank(time)) { 423 | time = "235959"; 424 | } 425 | return getDate(date, time); 426 | } 427 | 428 | 429 | public static Timestamp asDateToTimestamp(){ 430 | return new java.sql.Timestamp(new java.util.Date().getTime()); 431 | } 432 | 433 | private static Date getDate(Date date, String time) { 434 | time = time.replaceAll("[/\\-:]", ""); 435 | Calendar calendar = Calendar.getInstance(); 436 | calendar.setTime(date); 437 | calendar.set(Calendar.DAY_OF_MONTH, 1); 438 | calendar.roll(Calendar.DAY_OF_MONTH, -1); 439 | calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time.substring(0, 2))); 440 | calendar.set(Calendar.MINUTE, Integer.parseInt(time.substring(2, 4))); 441 | calendar.set(Calendar.SECOND, Integer.parseInt(time.substring(4, 6))); 442 | return calendar.getTime(); 443 | } 444 | 445 | 446 | /** 447 | * 返回 {@link java.util.Calendar} 定义的日期域 448 | * 449 | * @param field 450 | * @return int 451 | */ 452 | private static int fieldParse(Field field) { 453 | switch (field) { 454 | case YEAR: 455 | return Calendar.YEAR; 456 | case MONTH: 457 | return Calendar.MONDAY; 458 | case WEEK: 459 | return Calendar.WEEK_OF_YEAR; 460 | case DAY: 461 | return Calendar.DAY_OF_MONTH; 462 | case HOUR: 463 | return Calendar.HOUR_OF_DAY; 464 | case MINUTE: 465 | return Calendar.MINUTE; 466 | case SECOND: 467 | return Calendar.SECOND; 468 | case MILLISECOND: 469 | return Calendar.MILLISECOND; 470 | } 471 | return Calendar.YEAR; 472 | } 473 | 474 | /** 475 | * 获取 对应日期的 对应值 476 | * 477 | * @param date 478 | * @param field 479 | * @return 480 | */ 481 | public static int field(Date date, Field field) { 482 | if (null == date) { 483 | date = new Date(); 484 | } 485 | Calendar calendar = Calendar.getInstance(); 486 | calendar.setTime(date); 487 | switch (field) { 488 | case YEAR: 489 | return calendar.get(Calendar.YEAR); 490 | case MONTH: 491 | calendar.add(Calendar.MONDAY, 1); 492 | return calendar.get(Calendar.MONDAY); 493 | case WEEK: 494 | return calendar.get(Calendar.WEEK_OF_YEAR); 495 | case DAY: 496 | return calendar.get(Calendar.DAY_OF_MONTH); 497 | case HOUR: 498 | return calendar.get(Calendar.HOUR_OF_DAY); 499 | case MINUTE: 500 | return calendar.get(Calendar.MINUTE); 501 | case SECOND: 502 | return calendar.get(Calendar.SECOND); 503 | case MILLISECOND: 504 | return calendar.get(Calendar.MILLISECOND); 505 | } 506 | return calendar.get(Calendar.YEAR); 507 | } 508 | 509 | } -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/CaptchaController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.IOException; 5 | 6 | import javax.annotation.Resource; 7 | import javax.imageio.ImageIO; 8 | import javax.servlet.ServletOutputStream; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import com.google.code.kaptcha.Constants; 18 | import com.google.code.kaptcha.Producer; 19 | 20 | /** 21 | * 验证码 控制器 22 | * http://localhost:8088/ticket-ssm/captcha/img 23 | * 配置文件在 resource文件夹里面spring-kaptcha.xml 24 | */ 25 | @Controller 26 | @RequestMapping("/captcha") 27 | public class CaptchaController { 28 | @Autowired 29 | HttpServletRequest request; 30 | @Autowired 31 | HttpServletResponse response; 32 | @Resource 33 | private Producer captchaProducer; 34 | 35 | // 图形验证码 36 | @RequestMapping("/img") 37 | public ModelAndView imageCode() { 38 | ServletOutputStream out = null; 39 | try { 40 | response.setDateHeader("Expires", 0); 41 | 42 | // Set standard HTTP/1.1 no-cache headers. 43 | 44 | response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); 45 | // Set IE extended HTTP/1.1 no-cache headers (use addHeader). 46 | 47 | response.addHeader("Cache-Control", "post-check=0, pre-check=0"); 48 | // Set standard HTTP/1.0 no-cache header. 49 | 50 | response.setHeader("Pragma", "no-cache"); 51 | // return a jpeg 52 | 53 | response.setContentType("image/jpeg"); 54 | // create the text for the image 55 | 56 | String capText = captchaProducer.createText(); 57 | // store the text in the session 58 | 59 | request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, capText); 60 | // create the image with the text 61 | 62 | BufferedImage bi = captchaProducer.createImage(capText); 63 | out = response.getOutputStream(); 64 | // write the data out 65 | 66 | ImageIO.write(bi, "jpg", out); 67 | 68 | out.flush(); 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | } finally { 72 | try { 73 | if (null != out) { 74 | out.close(); 75 | } 76 | } catch (IOException e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | return null; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | import com.java.ssm.ticket.service.ScenicService; 10 | 11 | 12 | /** 13 | * 用户试图处理器 14 | * @author hgy 15 | */ 16 | @Controller 17 | @RequestMapping("/") 18 | public class IndexController { 19 | 20 | @Autowired 21 | ScenicService ss; 22 | 23 | 24 | //首页处理器 25 | @GetMapping(value = {"/index.html","/"}) 26 | public String index(Model ui) { 27 | //保持数据给前台渲染 28 | ui.addAttribute("ss", ss.getAll()); 29 | return "index"; 30 | } 31 | 32 | //登录处理器 33 | @RequestMapping("/login") 34 | public String login(Model ui){ 35 | ui.addAttribute("ss", ss.getAll()); 36 | return "login"; 37 | } 38 | 39 | //注册处理器 40 | @RequestMapping("/register") 41 | public String register(Model ui){ 42 | ui.addAttribute("ss", ss.getAll()); 43 | return "register"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | 9 | import com.java.ssm.ticket.service.OrderService; 10 | 11 | /** 12 | * 订单控制器 13 | */ 14 | @Controller 15 | @RequestMapping("/order") 16 | public class OrderController { 17 | 18 | @Autowired 19 | OrderService os; 20 | 21 | @GetMapping("/list") 22 | public String orderList(Model ui) { 23 | ui.addAttribute("OL", os.asUserOfOrderList()); 24 | return "orderList"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/ReserveConteroller.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | import com.java.ssm.ticket.model.Scenic; 18 | import com.java.ssm.ticket.service.OrderService; 19 | import com.java.ssm.ticket.service.ScenicService; 20 | 21 | /** 22 | * 预定控制器 23 | */ 24 | @Controller 25 | @RequestMapping("/") 26 | public class ReserveConteroller { 27 | 28 | @Autowired 29 | ScenicService ss; 30 | @Autowired 31 | OrderService os; 32 | 33 | /** 34 | * 渲染reserve页面数据 35 | */ 36 | @GetMapping("/reserve/{sid}") 37 | public String reserve(@PathVariable String sid,Model md) { 38 | if(sid == null) { 39 | //空的话就初始化 40 | sid = "1"; 41 | } 42 | Scenic sc = ss.getScenicBySid(sid); 43 | md.addAttribute("sc", sc); 44 | return "reserve"; 45 | } 46 | 47 | 48 | 49 | 50 | @ResponseBody 51 | @PostMapping("/reserve/order") 52 | public Map toReserve(@RequestParam String sid,@RequestParam String count) { 53 | Map result = new HashMap(); 54 | if(sid == null || count==null) { 55 | result.put("status", 500); 56 | result.put("msg", "参数错误!下单失败!"); 57 | return result; 58 | } 59 | //下单服务 true就表示执行成功 60 | if(os.putReserveOrder(sid, count)) { 61 | result.put("status", 200); 62 | result.put("totalPrice", totalPrice(ss.getScenicBySid(sid).getScenicPrice(), Integer.valueOf(count))); 63 | }else { 64 | result.put("status", 505); 65 | result.put("msg", "创建订单发生异常!下单失败!"); 66 | } 67 | return result; 68 | } 69 | 70 | 71 | 72 | 73 | //计算总价 74 | public BigDecimal totalPrice(BigDecimal price,Integer count) { 75 | return price.multiply(BigDecimal.valueOf(count)); 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/ScenicController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | 10 | import com.java.ssm.ticket.service.ScenicService; 11 | 12 | /** 13 | * 景点详情和购买控制器 14 | */ 15 | @Controller 16 | @RequestMapping("/Scenic") 17 | public class ScenicController { 18 | 19 | 20 | @Autowired 21 | ScenicService ss; 22 | 23 | /** 24 | * 详情请求 25 | * @param id 景点id 26 | * @return 详情视图 27 | */ 28 | @GetMapping("/details/{id}") 29 | public String details(@PathVariable String id,Model ui) { 30 | //防止id为空 并且 如果空就负默认值为1 31 | if (id == null) { 32 | id = String.valueOf(1); 33 | } 34 | ss.addOneStar(id); 35 | ui.addAttribute("details", ss.getScenicBySid(id)); 36 | return "details"; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/SearchConteroller.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestParam; 11 | 12 | import com.java.ssm.ticket.model.Scenic; 13 | import com.java.ssm.ticket.service.ScenicService; 14 | 15 | /** 16 | * 搜索框控制器 17 | */ 18 | @Controller 19 | @RequestMapping("/") 20 | public class SearchConteroller { 21 | 22 | @Autowired 23 | ScenicService ss; 24 | 25 | /** 26 | * 处理搜索功能 27 | */ 28 | @GetMapping("/search") 29 | public String Scarch(@RequestParam String key,Model md) { 30 | if (key == null) { 31 | key = "鼎";// 如果是空就默认值 32 | } 33 | List sl = ss.searchKey(key); 34 | if(sl.size() == 0 || sl == null ) { 35 | md.addAttribute("sc", null); 36 | } else { 37 | md.addAttribute("sc", sl); 38 | } 39 | 40 | return "search"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/TestController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.ResponseBody; 10 | 11 | import com.java.ssm.ticket.model.Scenic; 12 | import com.java.ssm.ticket.service.ScenicService; 13 | 14 | /** 15 | * 开发过程中测试数据访问是否正常的控制器 16 | * http://localhost:8088/ticket-ssm/test/1 17 | */ 18 | @Controller 19 | @RequestMapping("/test") 20 | public class TestController { 21 | 22 | @Autowired 23 | ScenicService ss; 24 | 25 | 26 | /** 27 | * http://localhost:8088/ticket-ssm/test/1 28 | * @return 测试是否能获取scenic全部的数据 29 | */ 30 | @ResponseBody 31 | @GetMapping("/1") 32 | public List put1(){ 33 | return ss.getAll(); 34 | } 35 | 36 | /** 37 | * http://localhost:8088/ticket-ssm/test/2 38 | * @return 测试关键字搜索功能 39 | */ 40 | @ResponseBody 41 | @GetMapping("/2") 42 | public List put2(){ 43 | return ss.searchKey("测试"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/UserController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | import com.google.code.kaptcha.Constants; 14 | import com.java.ssm.ticket.model.User; 15 | import com.java.ssm.ticket.service.UserService; 16 | import com.java.ssm.ticket.utils.DateUtil; 17 | 18 | /** 19 | * 用户请求处理器 20 | * 21 | * @author hgy 22 | * 23 | */ 24 | @Controller 25 | @RequestMapping("/user") 26 | public class UserController { 27 | 28 | /** 29 | * session保存登录用户的key 30 | */ 31 | public static final String USER_LOGIN_KEY = "loginUserInfo"; 32 | 33 | @Autowired 34 | HttpServletResponse resp; 35 | 36 | @Autowired 37 | HttpServletRequest req; 38 | 39 | @Autowired 40 | UserService us; 41 | 42 | @PostMapping("/reg") 43 | public String register(User user, String captcha, Model md) { 44 | // 检查表单是否为空 长度是否为6位和8位 45 | 46 | // 开关 47 | boolean flag = true; 48 | if (user.getUsername() == null) { 49 | md.addAttribute("usermsg", "请填写你的名字!"); 50 | flag = false; 51 | } 52 | if (user.getIdcard() == null || user.getIdcard().getBytes().length < 18) { 53 | md.addAttribute("idmsg", "身份证号错误!"); 54 | flag = false; 55 | } 56 | if (user.getPassword() == null || user.getPassword().getBytes().length < 8) { 57 | md.addAttribute("pwdmsg", "密码长度是为8位!"); 58 | flag = false; 59 | } 60 | 61 | if (captcha == null || captcha.getBytes().length < 4) { 62 | md.addAttribute("codemsg", "验证码错误!"); 63 | flag = false; 64 | } 65 | 66 | // 如果表单验证不成功则转发到register页面 67 | // return !flag ? "forward:/register" : toReg(user,md); 68 | if (flag) { 69 | // 检查身份证是否被注册 70 | if (!us.checkUserIdCard(user.getIdcard())) { 71 | md.addAttribute("msg", "身份证号:" + user.getIdcard() + "已经被注册了!换一个试试~"); 72 | flag = false; 73 | } else {// 如果没有被注册去执行注册 74 | user.setCreateTime(DateUtil.asDateToTimestamp());//设置用户注册的时间 75 | if (us.registerOneUserInfo(user)) {// 是否为注册成功 76 | md.addAttribute("msg", "身份证号:" + user.getIdcard() + "注册成功!请去登录!"); 77 | return "forward:/register"; 78 | } else {// 没有注册成功 79 | md.addAttribute("msg", "注册失败!请去稍后重试!"); 80 | } 81 | } 82 | 83 | } 84 | return "forward:/register"; 85 | } 86 | 87 | // public String toReg(User user, Model ui) { 88 | // if (us.registerOneUserInfo(user)) { 89 | // ui.addAttribute("msg", "身份证号:" + user.getIdcard() + "注册成功!请去登录!"); 90 | // return "forward:/register"; 91 | // } 92 | // // ui.addAttribute("success-msg","注册失败!请去稍后重试!"); 93 | // return "forward:/register"; 94 | // } 95 | 96 | @PostMapping("/login") 97 | public String login(User user, String captcha, Model md) { 98 | // 检查表单是否为空 长度是否为6位和8位 99 | // 表单验证开关 100 | boolean flag = true; 101 | if (user.getIdcard() == null || user.getIdcard().getBytes().length == 0) { 102 | md.addAttribute("idmsg", "请检查你的身份证账号!"); 103 | flag = false; 104 | } 105 | if (user.getPassword() == null || user.getPassword().getBytes().length == 0) { 106 | md.addAttribute("pwdmsg", "请检查你的密码!"); 107 | flag = false; 108 | 109 | } 110 | // 从session里面取Kaptcha里面生成的值并且强转成String 111 | String cpaText = (String) req.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); 112 | // 检查验证码位数 和 是否和session中的一致 不一致则错误 113 | if (captcha == null || captcha.getBytes().length < 4 || !cpaText.equals(captcha)) { 114 | md.addAttribute("codemsg", "验证码错误!"); 115 | flag = false; 116 | } 117 | if (flag) {// 只有flag 是true的时候表面form args验证通过 118 | // 通过UserService检查用户输入的密码 119 | if (us.checkUserPassword(user)) { 120 | SessionLoginUser(user); 121 | return "redirect:/index.html"; 122 | } else { 123 | md.addAttribute("msg", "身份证号码或者密码错误!或者你身份证未注册~"); 124 | return "forward:/login"; 125 | } 126 | } 127 | // 如果执行到这里来说明用户表单数据没有验证通过 128 | return "forward:/login"; 129 | } 130 | 131 | 132 | 133 | @GetMapping("/logout") 134 | public String logout() { 135 | //移除保存在session中的用户信息 136 | req.getSession().removeAttribute(USER_LOGIN_KEY); 137 | return "redirect:/index.html"; 138 | } 139 | 140 | //登录普通用户 141 | public void SessionLoginUser(User user) { 142 | //user 是表单的user 我们不能直接使用 所以使用getUserByIdCard查询一下在使用 143 | User u = us.getUserByIdCard(user.getIdcard()); 144 | //将登录的用户保存在session中方便鉴权使用 145 | req.getSession().setAttribute(USER_LOGIN_KEY, u); 146 | } 147 | 148 | 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/com/java/ssm/ticket/view/admin/AdminController.java: -------------------------------------------------------------------------------- 1 | package com.java.ssm.ticket.view.admin; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.math.BigDecimal; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.UUID; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.Model; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PostMapping; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RequestParam; 19 | import org.springframework.web.bind.annotation.ResponseBody; 20 | import org.springframework.web.multipart.MultipartFile; 21 | 22 | import com.google.code.kaptcha.Constants; 23 | import com.java.ssm.ticket.model.Admin; 24 | import com.java.ssm.ticket.model.Scenic; 25 | import com.java.ssm.ticket.model.User; 26 | import com.java.ssm.ticket.service.AdminService; 27 | import com.java.ssm.ticket.service.OrderService; 28 | import com.java.ssm.ticket.service.ScenicService; 29 | import com.java.ssm.ticket.service.UserService; 30 | import com.java.ssm.ticket.utils.DateUtil; 31 | 32 | /** 33 | * 管理员控制器 34 | * 35 | */ 36 | @Controller 37 | @RequestMapping("/admin") 38 | public class AdminController { 39 | 40 | //文件存储地址 41 | public static final String PIC_URL= "http://localhost:8080/ticket-ssm/static/pic_upload/"; 42 | 43 | @Autowired 44 | AdminService as; 45 | 46 | @Autowired 47 | UserService us; 48 | 49 | @Autowired 50 | OrderService os; 51 | 52 | @Autowired 53 | ScenicService ss; 54 | 55 | @Autowired 56 | HttpServletRequest req; 57 | // 这些都是返回jsp视图 58 | @GetMapping("/login") 59 | public String admin() { 60 | return "admin/login"; 61 | } 62 | 63 | @GetMapping("/main") 64 | public String main() { 65 | return "admin/main"; 66 | } 67 | 68 | @GetMapping("/userList") 69 | public String userList(Model ui) { 70 | ui.addAttribute("us", us.getAllUsers()); 71 | return "admin/userList"; 72 | } 73 | 74 | @GetMapping("/orderList") 75 | public String orderList(Model ui) { 76 | ui.addAttribute("os", os.allOrders()); 77 | return "admin/orderList"; 78 | } 79 | 80 | @GetMapping("/scenicList") 81 | public String scenicList(Model ui) { 82 | ui.addAttribute("ss", ss.getAll()); 83 | return "admin/scenicList"; 84 | } 85 | 86 | @GetMapping("/addScenic") 87 | public String addScenic() { 88 | return "admin/addScenic"; 89 | } 90 | //返回编辑用户页面 91 | @GetMapping("/editUser") 92 | public String editUser(String uid, Model ui) { 93 | /* 94 | * if(uid == null || uid.isBlank()) { return "redirect:/admin/userList"; } 95 | */ 96 | ui.addAttribute("uid", uid); 97 | return "admin/editUser"; 98 | } 99 | //用户退出登录 从Session Remove的用户 100 | @GetMapping("/logout") 101 | public String logout() { 102 | req.getSession().removeAttribute("LOGIN_ADMIN"); 103 | return "redirect:/admin/login"; 104 | } 105 | //编辑用户请求 106 | @ResponseBody 107 | @PostMapping("/editUserform") 108 | public Map userForm(String uid, String username, String password) { 109 | Map rs = new HashMap(); 110 | if (username ==null || password == null || uid == null) { 111 | rs.put("code", "500"); 112 | rs.put("msg", "参数错误!"); 113 | return rs; 114 | } 115 | User user = us.getUserByUid(uid); 116 | user.setUsername(username); 117 | user.setPassword(password); 118 | if (us.updateUser(user)) { 119 | rs.put("code", 200); 120 | rs.put("msg", "成功~"); 121 | return rs; 122 | } 123 | rs.put("code", 500); 124 | rs.put("msg", "服务器错误!"); 125 | return rs; 126 | } 127 | //删除用户请求 128 | @ResponseBody 129 | @PostMapping("/delUserform") 130 | public Map delUserForm(String uid) { 131 | Map rs = new HashMap(); 132 | if ( uid == null) { 133 | rs.put("code", "500"); 134 | rs.put("msg", "参数错误!"); 135 | return rs; 136 | } 137 | 138 | if (us.delUserByUid(uid)) { 139 | rs.put("code", 200); 140 | rs.put("msg", "成功~"); 141 | return rs; 142 | } 143 | rs.put("code", 500); 144 | rs.put("msg", "服务器错误!"); 145 | return rs; 146 | } 147 | //删除景点 148 | @ResponseBody 149 | @PostMapping("/delScenicform") 150 | public Map delScenicform(String sid) { 151 | Map rs = new HashMap(); 152 | if (sid == null) { 153 | rs.put("code", "500"); 154 | rs.put("msg", "参数错误!"); 155 | return rs; 156 | } 157 | 158 | if (ss.deleteScenicById(sid)) { 159 | rs.put("code", 200); 160 | rs.put("msg", "成功~"); 161 | return rs; 162 | } 163 | rs.put("code", 500); 164 | rs.put("msg", "服务器错误!"); 165 | return rs; 166 | } 167 | //删除订单 168 | @ResponseBody 169 | @PostMapping("/delOrderform") 170 | public Map delOrderForm(String oid) { 171 | Map rs = new HashMap(); 172 | if (oid == null) { 173 | rs.put("code", "500"); 174 | rs.put("msg", "参数错误!"); 175 | return rs; 176 | } 177 | 178 | if (os.delOneOrder(oid)) { 179 | rs.put("code", 200); 180 | rs.put("msg", "成功~"); 181 | return rs; 182 | } 183 | rs.put("code", 500); 184 | rs.put("msg", "服务器错误!"); 185 | return rs; 186 | } 187 | //登录表单验证 188 | @ResponseBody 189 | @PostMapping("/form") 190 | public Map form(String code, Admin admin) { 191 | Map rs = new HashMap(); 192 | // 从session里面取Kaptcha里面生成的值并且强转成String 193 | String cpaText = (String) req.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); 194 | if (!code.equals(cpaText)) { 195 | rs.put("code", "500"); 196 | rs.put("msg", "验证码错误!"); 197 | return rs; 198 | } 199 | if (as.checkAdmin(admin)) { 200 | rs.put("code", 200); 201 | rs.put("msg", "登录成功~"); 202 | return rs; 203 | } 204 | rs.put("code", 500); 205 | rs.put("msg", "账号或者密码错误!"); 206 | return rs; 207 | } 208 | //添加景点请求 209 | @ResponseBody 210 | @PostMapping("/addScform") 211 | public Map addScform(String sc_name,String sc_address, String sc_desc, 212 | String sc_price,String sc_pic) { 213 | Map rs = new HashMap(); 214 | System.out.println(sc_name + sc_address + sc_desc + sc_name + sc_price); 215 | if (sc_name == null || sc_address ==null || sc_desc==null || sc_name==null || sc_price==null) { 216 | rs.put("code", "500"); 217 | rs.put("msg", "验证码错误!"); 218 | return rs; 219 | } 220 | Scenic sc = new Scenic(); 221 | sc.setScenicName(sc_name); 222 | sc.setCreateTime(DateUtil.asDateToTimestamp()); 223 | sc.setScenicAddress(sc_address); 224 | sc.setScenicDetails(sc_desc); 225 | sc.setScenicPrice(new BigDecimal(sc_price)); 226 | sc.setScenicPic(PIC_URL+sc_pic); 227 | sc.setScenicStar(0); 228 | if (ss.saveScenic(sc)) { 229 | rs.put("code", 200); 230 | rs.put("msg", "成功~"); 231 | return rs; 232 | } 233 | rs.put("code", 500); 234 | rs.put("msg", "服务器错误!"); 235 | return rs; 236 | } 237 | //景点图片上传接口 238 | @ResponseBody 239 | @PostMapping("/pic_upload") 240 | public Map pic_upload(@RequestParam MultipartFile file) { 241 | Map rs = new HashMap(); 242 | if (file == null) { 243 | rs.put("code", 500); 244 | rs.put("msg", "上传图片失败!"); 245 | return rs; 246 | } 247 | String fileName = null; 248 | String uploadRootPath = null; 249 | try { 250 | // 获取目录/创建路径 251 | uploadRootPath = req.getServletContext().getRealPath("static/pic_upload/"); 252 | String contexPath= req.getSession().getServletContext().getRealPath("/"); 253 | 254 | System.out.println("lujign ="+contexPath); 255 | // 获取文件名 256 | fileName = file.getOriginalFilename(); 257 | // 获取文件后缀名 258 | String suffixName = fileName.substring(fileName.lastIndexOf(".")); 259 | // 重新生成文件名 260 | fileName = UUID.randomUUID() + suffixName; 261 | // 将图片保存到static文件夹里 262 | file.transferTo(new File(uploadRootPath + fileName)); 263 | } catch (IllegalStateException e) { 264 | rs.put("code", 500); 265 | rs.put("msg", "上传图片失败!"); 266 | e.printStackTrace(); 267 | } catch (IOException e) { 268 | rs.put("code", 500); 269 | rs.put("msg", "上传图片失败!"); 270 | e.printStackTrace(); 271 | } 272 | rs.put("code", 200); 273 | rs.put("msg", "上传成功!"); 274 | rs.put("pic", fileName); 275 | System.out.println(uploadRootPath + fileName); 276 | return rs; 277 | } 278 | 279 | 280 | 281 | } 282 | -------------------------------------------------------------------------------- /src/test/java/test/test.java: -------------------------------------------------------------------------------- 1 | //package test; 2 | // 3 | //import org.junit.Test; 4 | // 5 | //public class test { 6 | // 7 | // @Test 8 | // public void test1() { 9 | // String username = "abc.123456"; 10 | // System.out.println(username.getBytes().length); 11 | // } 12 | //} 13 | -------------------------------------------------------------------------------- /ticket-ssm.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | --------------------------------------------------------------------------------