├── .gitignore
├── README.md
├── demo_springboot
├── .gitignore
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── mvnw
├── mvnw.cmd
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── kay
│ │ │ ├── DemoSpringbootApplication.java
│ │ │ ├── config
│ │ │ ├── dao
│ │ │ │ ├── DataSourceConfiguration.java
│ │ │ │ └── SqlSessionFacoryConfiguration.java
│ │ │ └── service
│ │ │ │ └── TransactionManagerConfiguration.java
│ │ │ ├── dao
│ │ │ └── TbAreaMapper.java
│ │ │ ├── entity
│ │ │ └── TbArea.java
│ │ │ ├── handler
│ │ │ └── GlobalException.java
│ │ │ ├── service
│ │ │ ├── AreaService.java
│ │ │ └── impl
│ │ │ │ └── AreaServiceImpl.java
│ │ │ └── web
│ │ │ └── AreaController.java
│ └── resources
│ │ ├── application.properties
│ │ ├── generatorConfig.xml
│ │ ├── mapper
│ │ └── TbAreaMapper.xml
│ │ └── mybatis-config.xml
│ └── test
│ └── java
│ └── com
│ └── kay
│ └── DemoSpringbootApplicationTests.java
└── wechat
├── app.js
├── app.json
├── app.wxss
├── pages
├── index
│ ├── index.js
│ ├── index.wxml
│ └── index.wxss
├── list
│ ├── list.js
│ ├── list.json
│ ├── list.wxml
│ └── list.wxss
├── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
└── operation
│ ├── operation.js
│ ├── operation.json
│ ├── operation.wxml
│ └── operation.wxss
├── project.config.json
└── utils
└── util.js
/.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 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wechat_springboot
2 | 微信小程序入门
3 |
--------------------------------------------------------------------------------
/demo_springboot/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/demo_springboot/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuKay/wechat_springboot/a50325d521c016e1bb56758995bab04519cbc7a3/demo_springboot/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/demo_springboot/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
2 |
--------------------------------------------------------------------------------
/demo_springboot/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/demo_springboot/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/demo_springboot/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.kay
7 | demo_springboot
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | demo_springboot
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 2.0.0.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.8
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 | org.mybatis.spring.boot
34 | mybatis-spring-boot-starter
35 | 1.3.2
36 |
37 |
38 |
39 | mysql
40 | mysql-connector-java
41 | 8.0.16
42 |
43 |
44 |
45 | com.mchange
46 | c3p0
47 | 0.9.5.4
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-test
53 | test
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | org.mybatis.generator
62 | mybatis-generator-maven-plugin
63 | 1.3.2
64 |
65 | true
66 | true
67 | src/main/resources/generatorConfig.xml
68 |
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-maven-plugin
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/DemoSpringbootApplication.java:
--------------------------------------------------------------------------------
1 | package com.kay;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoSpringbootApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoSpringbootApplication.class, args);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/config/dao/DataSourceConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.kay.config.dao;
2 |
3 | import com.mchange.v2.c3p0.ComboPooledDataSource;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.beans.factory.annotation.Value;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | import javax.sql.DataSource;
10 | import java.beans.PropertyVetoException;
11 |
12 | /**
13 | * Created by kay on 2018/3/16.
14 | */
15 | @Configuration
16 | @MapperScan("com.kay.dao")
17 | public class DataSourceConfiguration {
18 |
19 | @Value("${jdbc.driver}")
20 | private String jdbcDriverClass;
21 |
22 | @Value("${jdbc.url}")
23 | private String jdbcUrl;
24 |
25 | @Value("${jdbc.user}")
26 | private String jdbcUser;
27 |
28 | @Value("${jdbc.password}")
29 | private String jdbcPwd;
30 |
31 | @Bean(name="dataSource")
32 | public DataSource getDataSource() throws PropertyVetoException {
33 | ComboPooledDataSource dataSource = new ComboPooledDataSource();
34 | dataSource.setDriverClass(jdbcDriverClass);
35 | dataSource.setJdbcUrl(jdbcUrl);
36 | dataSource.setUser(jdbcUser);
37 | dataSource.setPassword(jdbcPwd);
38 | dataSource.setAutoCommitOnClose(false);
39 | return dataSource;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/config/dao/SqlSessionFacoryConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.kay.config.dao;
2 |
3 | import org.mybatis.spring.SqlSessionFactoryBean;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.beans.factory.annotation.Qualifier;
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 | import org.springframework.core.io.ClassPathResource;
10 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
11 |
12 | import javax.sql.DataSource;
13 | import java.io.IOException;
14 |
15 | /**
16 | * Created by kay on 2018/3/16.
17 | */
18 | @Configuration
19 | public class SqlSessionFacoryConfiguration {
20 |
21 | @Value("${mybatis_config_file}")
22 | private String mybatisConfigPath;
23 |
24 | @Value("${mapper_path}")
25 | private String mapperPath;
26 |
27 | @Value("${entity_package}")
28 | private String entityPackage;
29 |
30 | @Autowired
31 | @Qualifier("dataSource")
32 | private DataSource dataSource;
33 |
34 |
35 | @Bean("sqlSessionFactory")
36 | public SqlSessionFactoryBean creatSqlSessionFactory() throws IOException {
37 | SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
38 | sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigPath));
39 | PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
40 | String packSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_URL_PREFIX;
41 | sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packSearchPath+mapperPath));
42 | sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage);
43 | sqlSessionFactoryBean.setDataSource(dataSource);
44 | return sqlSessionFactoryBean;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/config/service/TransactionManagerConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.kay.config.service;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
6 | import org.springframework.transaction.PlatformTransactionManager;
7 | import org.springframework.transaction.annotation.TransactionManagementConfigurer;
8 |
9 | import javax.sql.DataSource;
10 |
11 | /**
12 | * Created by kay on 2018/3/16.
13 | */
14 | @Configuration
15 | public class TransactionManagerConfiguration implements TransactionManagementConfigurer {
16 |
17 | @Autowired
18 | private DataSource dataSource;
19 |
20 | @Override
21 | public PlatformTransactionManager annotationDrivenTransactionManager() {
22 | return new DataSourceTransactionManager(dataSource);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/dao/TbAreaMapper.java:
--------------------------------------------------------------------------------
1 | package com.kay.dao;
2 |
3 | import com.kay.entity.TbArea;
4 |
5 | import java.util.List;
6 |
7 | public interface TbAreaMapper {
8 | int deleteByPrimaryKey(Integer areaId);
9 |
10 | int insert(TbArea record);
11 |
12 | int insertSelective(TbArea record);
13 |
14 | TbArea selectByPrimaryKey(Integer areaId);
15 |
16 | int updateByPrimaryKeySelective(TbArea record);
17 |
18 | int updateByPrimaryKey(TbArea record);
19 |
20 | List queryArea();
21 | }
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/entity/TbArea.java:
--------------------------------------------------------------------------------
1 | package com.kay.entity;
2 |
3 | import java.util.Date;
4 |
5 | public class TbArea {
6 | private Integer areaId;
7 |
8 | private String areaName;
9 |
10 | private Integer priority;
11 |
12 | private Date createTime;
13 |
14 | private Date updateTime;
15 |
16 | public Integer getAreaId() {
17 | return areaId;
18 | }
19 |
20 | public void setAreaId(Integer areaId) {
21 | this.areaId = areaId;
22 | }
23 |
24 | public String getAreaName() {
25 | return areaName;
26 | }
27 |
28 | public void setAreaName(String areaName) {
29 | this.areaName = areaName == null ? null : areaName.trim();
30 | }
31 |
32 | public Integer getPriority() {
33 | return priority;
34 | }
35 |
36 | public void setPriority(Integer priority) {
37 | this.priority = priority;
38 | }
39 |
40 | public Date getCreateTime() {
41 | return createTime;
42 | }
43 |
44 | public void setCreateTime(Date createTime) {
45 | this.createTime = createTime;
46 | }
47 |
48 | public Date getUpdateTime() {
49 | return updateTime;
50 | }
51 |
52 | public void setUpdateTime(Date updateTime) {
53 | this.updateTime = updateTime;
54 | }
55 | }
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/handler/GlobalException.java:
--------------------------------------------------------------------------------
1 | package com.kay.handler;
2 |
3 | import org.springframework.web.bind.annotation.ControllerAdvice;
4 | import org.springframework.web.bind.annotation.ExceptionHandler;
5 | import org.springframework.web.bind.annotation.ResponseBody;
6 |
7 | import javax.servlet.http.HttpServletRequest;
8 | import java.util.HashMap;
9 | import java.util.Map;
10 |
11 | /**
12 | * Created by kay on 2018/3/16.
13 | *
14 | * 示例写法
15 | * 需针对每个异常写一个handler处理器
16 | *
17 | */
18 | @ControllerAdvice
19 | public class GlobalException {
20 |
21 | @ExceptionHandler(value = Exception.class)
22 | @ResponseBody
23 | private Map exceptionHandler(HttpServletRequest request,Exception e) {
24 | Map modelMap = new HashMap();
25 | modelMap.put("success", false);
26 | modelMap.put("errMsg", e.getMessage());
27 | return modelMap;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/service/AreaService.java:
--------------------------------------------------------------------------------
1 | package com.kay.service;
2 |
3 | import com.kay.entity.TbArea;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by kay on 2018/3/16.
9 | */
10 | public interface AreaService {
11 |
12 | boolean deleteByPrimaryKey(Integer areaId);
13 |
14 | boolean insert(TbArea record);
15 |
16 | int insertSelective(TbArea record);
17 |
18 | TbArea selectByPrimaryKey(Integer areaId);
19 |
20 | boolean updateByPrimaryKeySelective(TbArea record);
21 |
22 | int updateByPrimaryKey(TbArea record);
23 |
24 | List queryArea();
25 | }
26 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/service/impl/AreaServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.kay.service.impl;
2 |
3 | import com.kay.dao.TbAreaMapper;
4 | import com.kay.entity.TbArea;
5 | import com.kay.service.AreaService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.annotation.Transactional;
9 |
10 | import java.util.Date;
11 | import java.util.List;
12 |
13 | /**
14 | * Created by kay on 2018/3/16.
15 | */
16 | @Service
17 | public class AreaServiceImpl implements AreaService {
18 |
19 | @Autowired
20 | private TbAreaMapper areaMapper;
21 |
22 | @Override
23 | public boolean deleteByPrimaryKey(Integer areaId) {
24 | int deleteCount = areaMapper.deleteByPrimaryKey(areaId);
25 | if(deleteCount>0){
26 | return true;
27 | }else {
28 | return false;
29 | }
30 | }
31 |
32 | @Transactional
33 | @Override
34 | public boolean insert(TbArea area) {
35 | if (area.getAreaName()!=null && !"".equals(area.getAreaName())) {
36 | area.setCreateTime(new Date());
37 | area.setUpdateTime(new Date());
38 | try {
39 | int insertCount = areaMapper.insert(area);
40 | if (insertCount > 0) {
41 | return true;
42 | } else {
43 | throw new RuntimeException("插入失败");
44 | }
45 | } catch (Exception e) {
46 | throw new RuntimeException("插入失败"+ e.getMessage());
47 | }
48 | }else {
49 | throw new RuntimeException("区域信息不能为空");
50 | }
51 | }
52 |
53 | @Override
54 | public int insertSelective(TbArea record) {
55 | return areaMapper.insertSelective(record);
56 | }
57 |
58 | @Override
59 | public TbArea selectByPrimaryKey(Integer areaId) {
60 | return areaMapper.selectByPrimaryKey(areaId);
61 | }
62 |
63 | @Override
64 | public boolean updateByPrimaryKeySelective(TbArea record) {
65 | if (record.getAreaName()!=null && !"".equals(record.getAreaName())) {
66 | record.setUpdateTime(new Date());
67 | try {
68 | int updateCount = areaMapper.updateByPrimaryKeySelective(record);
69 | if (updateCount > 0) {
70 | return true;
71 | } else {
72 | throw new RuntimeException("更新失败");
73 | }
74 | } catch (Exception e) {
75 | throw new RuntimeException("更新失败"+ e.getMessage());
76 | }
77 | }else {
78 | throw new RuntimeException("区域信息不能为空");
79 | }
80 | }
81 |
82 | @Override
83 | public int updateByPrimaryKey(TbArea record) {
84 | return areaMapper.updateByPrimaryKey(record);
85 | }
86 |
87 | @Override
88 | public List queryArea() {
89 | return areaMapper.queryArea();
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/java/com/kay/web/AreaController.java:
--------------------------------------------------------------------------------
1 | package com.kay.web;
2 |
3 | import com.kay.entity.TbArea;
4 | import com.kay.service.AreaService;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.RequestBody;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RequestMethod;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | import java.util.HashMap;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | /**
16 | * Created by kay on 2018/3/16.
17 | */
18 | @RestController
19 | @RequestMapping("/superadmin")
20 | public class AreaController {
21 |
22 | @Autowired
23 | private AreaService areaService;
24 |
25 | /**
26 | * 列表查询
27 | * @return
28 | */
29 | @RequestMapping(value = "/listarea",method = RequestMethod.GET)
30 | private Map listArea() {
31 | Map modelMap = new HashMap();
32 | List areas = areaService.queryArea();
33 | modelMap.put("areaList", areas);
34 | return modelMap;
35 | }
36 |
37 | /**
38 | * areaid 查询
39 | * @param areaId
40 | * @return
41 | */
42 | @RequestMapping(value = "/getareabyid",method = RequestMethod.GET)
43 | private Map getAreaById(Integer areaId) {
44 | Map modelMap = new HashMap();
45 | TbArea area = areaService.selectByPrimaryKey(areaId);
46 | modelMap.put("area", area);
47 | return modelMap;
48 | }
49 |
50 | /**
51 | * 添加area
52 | * @param area
53 | * @return
54 | */
55 | @RequestMapping(value = "/addarea",method = RequestMethod.POST)
56 | private Map addArea(@RequestBody TbArea area) {
57 | Map modelMap = new HashMap();
58 | boolean isSuccess = areaService.insert(area);
59 | modelMap.put("success", isSuccess);
60 | return modelMap;
61 | }
62 |
63 | /**
64 | * 修改
65 | * @param area
66 | * @return
67 | */
68 | @RequestMapping(value = "/modifyarea",method = RequestMethod.POST)
69 | private Map modifyArea(@RequestBody TbArea area) {
70 | Map modelMap = new HashMap();
71 | boolean b = areaService.updateByPrimaryKeySelective(area);
72 | modelMap.put("success", b);
73 | return modelMap;
74 | }
75 |
76 | /**
77 | * 删除area
78 | * @param areaId
79 | * @return
80 | */
81 | @RequestMapping(value = "/removearea",method = RequestMethod.GET)
82 | private Map removeArea(Integer areaId) {
83 | Map modelMap = new HashMap();
84 | boolean isSuccess = areaService.deleteByPrimaryKey(areaId);
85 | modelMap.put("success", isSuccess);
86 | return modelMap;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8081
2 |
3 | jdbc.driver=com.mysql.jdbc.Driver
4 | jdbc.url=jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8
5 | jdbc.user=root
6 | jdbc.password=lk123456
7 |
8 | #mybatis
9 | mybatis_config_file=mybatis-config.xml
10 | mapper_path=/mapper/**.xml
11 | entity_package=com.kay.entity
--------------------------------------------------------------------------------
/demo_springboot/src/main/resources/generatorConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
39 |
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
50 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/resources/mapper/TbAreaMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | area_id, area_name, priority, create_time, update_time
13 |
14 |
20 |
25 |
26 | delete from tb_area
27 | where area_id = #{areaId,jdbcType=INTEGER}
28 |
29 |
31 | insert into tb_area (area_id, area_name, priority,
32 | create_time, update_time)
33 | values (#{areaId,jdbcType=INTEGER}, #{areaName,jdbcType=VARCHAR}, #{priority,jdbcType=INTEGER},
34 | #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
35 |
36 |
37 | insert into tb_area
38 |
39 |
40 | area_id,
41 |
42 |
43 | area_name,
44 |
45 |
46 | priority,
47 |
48 |
49 | create_time,
50 |
51 |
52 | update_time,
53 |
54 |
55 |
56 |
57 | #{areaId,jdbcType=INTEGER},
58 |
59 |
60 | #{areaName,jdbcType=VARCHAR},
61 |
62 |
63 | #{priority,jdbcType=INTEGER},
64 |
65 |
66 | #{createTime,jdbcType=TIMESTAMP},
67 |
68 |
69 | #{updateTime,jdbcType=TIMESTAMP},
70 |
71 |
72 |
73 |
74 | update tb_area
75 |
76 |
77 | area_name = #{areaName,jdbcType=VARCHAR},
78 |
79 |
80 | priority = #{priority,jdbcType=INTEGER},
81 |
82 |
83 | create_time = #{createTime,jdbcType=TIMESTAMP},
84 |
85 |
86 | update_time = #{updateTime,jdbcType=TIMESTAMP},
87 |
88 |
89 | where area_id = #{areaId,jdbcType=INTEGER}
90 |
91 |
92 | update tb_area
93 | set area_name = #{areaName,jdbcType=VARCHAR},
94 | priority = #{priority,jdbcType=INTEGER},
95 | create_time = #{createTime,jdbcType=TIMESTAMP},
96 | update_time = #{updateTime,jdbcType=TIMESTAMP}
97 | where area_id = #{areaId,jdbcType=INTEGER}
98 |
99 |
--------------------------------------------------------------------------------
/demo_springboot/src/main/resources/mybatis-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/demo_springboot/src/test/java/com/kay/DemoSpringbootApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.kay;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class DemoSpringbootApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/wechat/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | // 展示本地存储能力
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 |
9 | // 登录
10 | wx.login({
11 | success: res => {
12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId
13 | }
14 | })
15 | // 获取用户信息
16 | wx.getSetting({
17 | success: res => {
18 | if (res.authSetting['scope.userInfo']) {
19 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
20 | wx.getUserInfo({
21 | success: res => {
22 | // 可以将 res 发送给后台解码出 unionId
23 | this.globalData.userInfo = res.userInfo
24 |
25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
26 | // 所以此处加入 callback 以防止这种情况
27 | if (this.userInfoReadyCallback) {
28 | this.userInfoReadyCallback(res)
29 | }
30 | }
31 | })
32 | }
33 | }
34 | })
35 | },
36 | globalData: {
37 | userInfo: null
38 | }
39 | })
--------------------------------------------------------------------------------
/wechat/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/logs/logs",
5 | "pages/list/list",
6 | "pages/operation/operation"
7 | ],
8 | "window": {
9 | "backgroundTextStyle": "light",
10 | "navigationBarBackgroundColor": "#fff",
11 | "navigationBarTitleText": "WeChat",
12 | "navigationBarTextStyle": "black"
13 | }
14 | }
--------------------------------------------------------------------------------
/wechat/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/wechat/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //index.js
2 | //获取应用实例
3 | const app = getApp()
4 |
5 | Page({
6 | data: {
7 | motto: 'Hello World',
8 | userInfo: {},
9 | hasUserInfo: false,
10 | canIUse: wx.canIUse('button.open-type.getUserInfo')
11 | },
12 | //事件处理函数
13 | bindViewTap: function() {
14 | wx.navigateTo({
15 | url: '../list/list'
16 | })
17 | },
18 | onLoad: function () {
19 | if (app.globalData.userInfo) {
20 | this.setData({
21 | userInfo: app.globalData.userInfo,
22 | hasUserInfo: true
23 | })
24 | } else if (this.data.canIUse){
25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
26 | // 所以此处加入 callback 以防止这种情况
27 | app.userInfoReadyCallback = res => {
28 | this.setData({
29 | userInfo: res.userInfo,
30 | hasUserInfo: true
31 | })
32 | }
33 | } else {
34 | // 在没有 open-type=getUserInfo 版本的兼容处理
35 | wx.getUserInfo({
36 | success: res => {
37 | app.globalData.userInfo = res.userInfo
38 | this.setData({
39 | userInfo: res.userInfo,
40 | hasUserInfo: true
41 | })
42 | }
43 | })
44 | }
45 | },
46 | getUserInfo: function(e) {
47 | console.log(e)
48 | app.globalData.userInfo = e.detail.userInfo
49 | this.setData({
50 | userInfo: e.detail.userInfo,
51 | hasUserInfo: true
52 | })
53 | }
54 | })
55 |
--------------------------------------------------------------------------------
/wechat/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{motto}}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/wechat/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .userinfo {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | }
7 |
8 | .userinfo-avatar {
9 | width: 128rpx;
10 | height: 128rpx;
11 | margin: 20rpx;
12 | border-radius: 50%;
13 | }
14 |
15 | .userinfo-nickname {
16 | color: #aaa;
17 | }
18 |
19 | .usermotto {
20 | margin-top: 200px;
21 | }
--------------------------------------------------------------------------------
/wechat/pages/list/list.js:
--------------------------------------------------------------------------------
1 | // pages/list/list.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | list:[]
9 | },
10 |
11 | /**
12 | * 生命周期函数--监听页面加载
13 | */
14 | onLoad: function (options) {
15 |
16 | },
17 |
18 | /**
19 | * 生命周期函数--监听页面初次渲染完成
20 | */
21 | onReady: function () {
22 |
23 | },
24 |
25 | /**
26 | * 生命周期函数--监听页面显示
27 | */
28 | onShow: function () {
29 | var that=this;
30 | wx.request({
31 | url: 'http://127.0.0.1:8081/superadmin/listarea',
32 | method:'GET',
33 | data:{},
34 | success:function(res){
35 | var list=res.data.areaList;
36 | if(list==null){
37 | var toastText='获取数据失败'+res.data.errMsg;
38 | wx.showToast({
39 | title: toastText,
40 | icon:'',
41 | duration:2000 //弹出时间
42 | })
43 | }else{
44 | that.setData({
45 | list:list
46 | })
47 | }
48 | }
49 | })
50 | },
51 |
52 | /**
53 | * 生命周期函数--监听页面隐藏
54 | */
55 | onHide: function () {
56 |
57 | },
58 |
59 | /**
60 | * 生命周期函数--监听页面卸载
61 | */
62 | onUnload: function () {
63 |
64 | },
65 |
66 | /**
67 | * 页面相关事件处理函数--监听用户下拉动作
68 | */
69 | onPullDownRefresh: function () {
70 |
71 | },
72 |
73 | /**
74 | * 页面上拉触底事件的处理函数
75 | */
76 | onReachBottom: function () {
77 |
78 | },
79 |
80 | /**
81 | * 用户点击右上角分享
82 | */
83 | onShareAppMessage: function () {
84 |
85 | },
86 | addArea:function(){
87 | wx.navigateTo({
88 | url:'../operation/operation'
89 | })
90 | },
91 | deleteArea: function (e) {
92 | var that=this;
93 |
94 | wx.showModal({
95 | title: '提示',
96 | content: '确定要删除[' + e.target.dataset.areaname +']吗?',
97 | success:function(sm){
98 | if(sm.confirm){
99 | wx.request({
100 | url: 'http://127.0.0.1:8081/superadmin/removearea',
101 | data: { 'areaId': e.target.dataset.areaid},
102 | method:'GET',
103 | success:function(res){
104 | var result=res.data.success;
105 | var toastText="删除成功";
106 | if(result!=true){
107 | toastText = "删除失败";
108 | }else{
109 | that.data.list.splice(e.target.dataset.index,1);
110 | that.setData({
111 | list:that.data.list
112 | });
113 | }
114 | wx.showToast({
115 | title: toastText,
116 | icon:'',
117 | duration:2000
118 | });
119 | }
120 | })
121 | }
122 | }
123 | })
124 |
125 |
126 | }
127 | })
--------------------------------------------------------------------------------
/wechat/pages/list/list.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "各校区列表"
3 | }
--------------------------------------------------------------------------------
/wechat/pages/list/list.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 编号
5 | 校区名
6 | 排名
7 | 操作
8 |
9 |
10 |
11 |
12 |
13 | {{item.areaId}}
14 | {{item.areaName}}
15 | {{item.priority}}
16 |
17 | 编辑 |
18 | 删除
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/wechat/pages/list/list.wxss:
--------------------------------------------------------------------------------
1 | /* pages/list/list.wxss */
2 | .container{
3 | height: 100%;
4 | display: table;
5 | align-items: center;
6 | justify-content: space-between;
7 | box-sizing: border-box;
8 | padding-top: 10rpx;
9 | padding-bottom: 10rpx;
10 | text-align: center;
11 | }
12 |
13 | .widget{
14 | position: relative;
15 | margin-top: 5rpx;
16 | margin-bottom: 5rpx;
17 | padding-top: 10rpx;
18 | padding-bottom: 10rpx;
19 | padding-left: 40rpx;
20 | padding-right: 40rpx;
21 | border: #ddd 1px solid;
22 | }
23 |
24 | .column{
25 | width: 4rem;
26 | display: table-cell;
27 | }
28 |
29 | .link-column{
30 | width: 6rem;
31 | display: table-cell;
32 | }
33 |
34 | .link{
35 | color: blue;
36 | display: inline-table;
37 |
38 | }
--------------------------------------------------------------------------------
/wechat/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | const util = require('../../utils/util.js')
3 |
4 | Page({
5 | data: {
6 | logs: []
7 | },
8 | onLoad: function () {
9 | this.setData({
10 | logs: (wx.getStorageSync('logs') || []).map(log => {
11 | return util.formatTime(new Date(log))
12 | })
13 | })
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/wechat/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/wechat/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/wechat/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/wechat/pages/operation/operation.js:
--------------------------------------------------------------------------------
1 | // pages/operation/operation.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | areaId:null,
9 | areaName:'',
10 | priority:'',
11 | addUrl:'http://127.0.0.1:8081/superadmin/addarea',
12 | modifyUrl:'http://127.0.0.1:8081/superadmin/modifyarea'
13 | },
14 |
15 | /**
16 | * 生命周期函数--监听页面加载
17 | */
18 | onLoad: function (options) {
19 | var that=this;
20 | if(options.areaId==undefined){
21 | return;
22 | }
23 | that.setData({
24 | areaId: options.areaId,
25 | });
26 | wx.request({
27 | url: 'http://127.0.0.1:8081/superadmin/getareabyid',
28 | data:{"areaId":options.areaId},
29 | method:'GET',
30 | success:function(res){
31 | var area=res.data.area;
32 | if(area==undefined){
33 | var text='获取数据失败'+res.data.errMsg;
34 | wx.showToast({
35 | title: text,
36 | icon:'',
37 | duration:2000
38 | });
39 | }else{
40 | that.setData({
41 | areaName:area.areaName,
42 | priority:area.priority
43 | })
44 | }
45 | }
46 | })
47 | },
48 |
49 | /**
50 | * 生命周期函数--监听页面初次渲染完成
51 | */
52 | onReady: function () {
53 |
54 | },
55 |
56 | /**
57 | * 生命周期函数--监听页面显示
58 | */
59 | onShow: function () {
60 |
61 | },
62 |
63 | /**
64 | * 生命周期函数--监听页面隐藏
65 | */
66 | onHide: function () {
67 |
68 | },
69 |
70 | /**
71 | * 生命周期函数--监听页面卸载
72 | */
73 | onUnload: function () {
74 |
75 | },
76 |
77 | /**
78 | * 页面相关事件处理函数--监听用户下拉动作
79 | */
80 | onPullDownRefresh: function () {
81 |
82 | },
83 |
84 | /**
85 | * 页面上拉触底事件的处理函数
86 | */
87 | onReachBottom: function () {
88 |
89 | },
90 |
91 | /**
92 | * 用户点击右上角分享
93 | */
94 | onShareAppMessage: function () {
95 |
96 | },
97 |
98 | /**
99 | * 表单功能
100 | */
101 | formSubmit:function(e){
102 | var that=this;
103 | var formData=e.detail.value; //获取表数据
104 | var url=that.data.addUrl; //默认url
105 | if(that.data.areaId!=undefined){
106 | formData.areaId=that.data.areaId;
107 | url = that.data.modifyUrl;
108 | }
109 | wx.request({
110 | url: url,
111 | data:JSON.stringify(formData),
112 | method:'POST',
113 | header:{
114 | 'Content-Type':'application/json'
115 | },
116 | success:function(res){
117 | var result=res.data.success;
118 | var toastText="操作成功";
119 | if(result!=true){
120 | toastText="操作失败!"+res.data.errMsg;
121 | }
122 | wx.showToast({
123 | title: toastText,
124 | icon:'',
125 | duration:3000
126 | });
127 |
128 | wx.redirectTo({
129 | url: '../list/list',
130 | })
131 | // if(that.data.areaId=undefined){
132 | // wx.redirectTo({
133 | // url: '../list/list',
134 | // })
135 | // }
136 | }
137 | })
138 | }
139 | })
--------------------------------------------------------------------------------
/wechat/pages/operation/operation.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "添加校区信息"
3 | }
--------------------------------------------------------------------------------
/wechat/pages/operation/operation.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
--------------------------------------------------------------------------------
/wechat/pages/operation/operation.wxss:
--------------------------------------------------------------------------------
1 | /* pages/operation/operation.wxss */
2 | .container {
3 | padding: 1rem;
4 | font-size: 0.9rem;
5 | line-height: 1.5rem;
6 | }
7 | .row {
8 | display: flex;
9 | align-items: center;
10 | margin-bottom: 0.8rem;
11 | }
12 | .row text {
13 | flex-grow: 1;
14 | text-align: right;
15 | }
16 | .row input {
17 | font-size: 0.7rem;
18 | flex-grow: 3;
19 | border: ipx solid #09c;
20 | display: inline-block;
21 | border-radius: 0.3rem;
22 | box-shadow: 0 0 0.15rem #aaa;
23 | padding: 0.3rem;
24 | }
25 | .row button {
26 | padding: 0.2rem;
27 | margin: 3rem 1rem;
28 | }
--------------------------------------------------------------------------------
/wechat/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "setting": {
4 | "urlCheck": false,
5 | "es6": true,
6 | "postcss": true,
7 | "minified": true,
8 | "newFeature": true
9 | },
10 | "compileType": "miniprogram",
11 | "libVersion": "1.9.93",
12 | "appid": "touristappid",
13 | "projectname": "AreaDemo",
14 | "condition": {
15 | "search": {
16 | "current": -1,
17 | "list": []
18 | },
19 | "conversation": {
20 | "current": -1,
21 | "list": []
22 | },
23 | "game": {
24 | "currentL": -1,
25 | "list": []
26 | },
27 | "miniprogram": {
28 | "current": -1,
29 | "list": []
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/wechat/utils/util.js:
--------------------------------------------------------------------------------
1 | const formatTime = date => {
2 | const year = date.getFullYear()
3 | const month = date.getMonth() + 1
4 | const day = date.getDate()
5 | const hour = date.getHours()
6 | const minute = date.getMinutes()
7 | const second = date.getSeconds()
8 |
9 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
10 | }
11 |
12 | const formatNumber = n => {
13 | n = n.toString()
14 | return n[1] ? n : '0' + n
15 | }
16 |
17 | module.exports = {
18 | formatTime: formatTime
19 | }
20 |
--------------------------------------------------------------------------------