瀏覽代碼

initproject

lijun 5 年之前
父節點
當前提交
3303faf6f4

+ 142 - 0
pom.xml

@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.caimei</groupId>
+    <artifactId>caimei-mall</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.9.RELEASE</version>
+    </parent>
+
+    <dependencies>
+        <!--spring Boot原始依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- 添加mybatis的核心包 -->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.3.1</version>
+        </dependency>
+
+        <!-- mysql的依赖 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.6</version>
+        </dependency>
+
+        <!-- 分页插件 -->
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.2.3</version>
+        </dependency>
+
+        <!--模板引擎-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <!--允许不严格的html5格式出现-->
+        <dependency>
+            <groupId>net.sourceforge.nekohtml</groupId>
+            <artifactId>nekohtml</artifactId>
+            <version>1.9.22</version>
+        </dependency>
+
+        <!--springboot使用tomcat容器-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <properties>
+                <!-- 环境标识,需要与配置文件的名称相对应 -->
+                <activatedProperties>dev</activatedProperties>
+            </properties>
+            <activation>
+                <!-- 默认环境 -->
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+        <profile>
+            <id>test</id>
+            <properties>
+                <activatedProperties>test</activatedProperties>
+            </properties>
+        </profile>
+        <profile>
+            <id>prod</id>
+            <properties>
+                <activatedProperties>prod</activatedProperties>
+            </properties>
+        </profile>
+    </profiles>
+
+    <build>
+        <resources>
+            <resource>
+                <!--配置文件路径  -->
+                <directory>src/main/resources</directory> <!--这里对应项目存放配置文件的目录-->
+                <!--开启filtering功能  -->
+                <filtering>true</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/resources/${activatedProperties}</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>1.5.2.RELEASE</version>
+                <configuration>
+                    <mainClass>lk.ArticleApplication</mainClass><!--springboot启动类目录-->
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <!--创建一个自动可执行的jar或war文件 -->
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 13 - 0
src/main/java/com/caimei/StartApplication.java

@@ -0,0 +1,13 @@
+package com.caimei;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class StartApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(StartApplication.class, args);
+    }
+
+}

+ 139 - 0
src/main/java/com/caimei/entity/Page.java

@@ -0,0 +1,139 @@
+package com.caimei.entity;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+public class Page<T> implements Serializable{
+	private static final long serialVersionUID = 1L;
+	private int index;//当前页码
+	private int pageSize;//每页大小
+	private int totalRecord;//总记录数
+	private int totalPage;//总页数?
+    private boolean hasNextPage;//是否有后一页
+    private boolean hasPreviousPage;//是否有前一页
+	List<T> results;//查询结果
+	
+	public Page(List<T> list){
+		if(list instanceof com.github.pagehelper.Page){
+			com.github.pagehelper.Page<T> page = (com.github.pagehelper.Page<T>)list;
+			this.index = page.getPageNum();
+			this.pageSize = page.getPageSize();
+			this.totalRecord = (int) page.getTotal();
+			this.totalPage = page.getPages();
+			setHasPreviousAndNext();
+			this.results = page;
+		}else if(list instanceof Collection){
+			this.index = 1;
+            this.pageSize = list.size();
+            this.totalRecord = list.size();
+            this.totalPage = 1;
+            this.results = list;
+		}
+	}
+	
+	public Page(int index, int pageSize, int totalRecord, List<T> results) {
+		super();
+		this.index = index;
+		this.pageSize = pageSize;
+		this.totalRecord = totalRecord;
+		this.totalPage = totalRecord % pageSize == 0 ? totalRecord/pageSize : totalRecord/pageSize+1;
+		this.results = results;
+		if(this.index<2){
+			hasPreviousPage=false;
+		}else{
+			hasPreviousPage=true;
+		}
+		if(this.index<totalPage){
+			hasNextPage = true;
+		}else{
+			hasNextPage = false;
+		}
+	}
+	
+	public Page(int index, int maxSize, int totalRecord, int totalPage,
+			List<T> results) {
+		super();
+		this.index = index;
+		this.pageSize = maxSize;
+		this.totalRecord = totalRecord;
+		this.totalPage = totalPage;
+		this.results = results;
+		if(this.index<2){
+			hasPreviousPage=false;
+		}else{
+			hasPreviousPage=true;
+		}
+		if(this.index<totalPage){
+			hasNextPage = true;
+		}else{
+			hasNextPage = false;
+		}
+	}
+	public void setHasPreviousAndNext(){
+		if(this.index<2){
+			hasPreviousPage=false;
+		}else{
+			hasPreviousPage=true;
+		}
+		if(this.index<totalPage){
+			hasNextPage = true;
+		}else{
+			hasNextPage = false;
+		}
+	}
+	
+	public Page() {
+		super();
+	}
+	public int getIndex() {
+		return index;
+	}
+	public void setIndex(int index) {
+		this.index = index;
+	}
+	public int getPageSize() {
+		return pageSize;
+	}
+	public void setPageSize(int maxSize) {
+		this.pageSize = maxSize;
+	}
+	public int getTotalRecord() {
+		return totalRecord;
+	}
+	public void setTotalRecord(int totalRecord) {
+		this.totalRecord = totalRecord;
+	}
+	public int getTotalPage() {
+		return totalPage;
+	}
+	public void setTotalPage(int totalPage) {
+		this.totalPage = totalPage;
+	}
+	public List<T> getResults() {
+		return results;
+	}
+	public void setResults(List<T> results) {
+		this.results = results;
+	}
+	
+	
+	public boolean isHasNextPage() {
+		return hasNextPage;
+	}
+	public void setHasNextPage(boolean hasNextPage) {
+		this.hasNextPage = hasNextPage;
+	}
+	public boolean isHasPreviousPage() {
+		return hasPreviousPage;
+	}
+	public void setHasPreviousPage(boolean hasPreviousPage) {
+		this.hasPreviousPage = hasPreviousPage;
+	}
+	public int countTotalPage(){
+		int total = totalRecord % pageSize == 0 ? totalRecord/pageSize : totalRecord/pageSize+1;
+		this.setTotalPage(total);
+	    return total;
+	}
+	
+}

+ 96 - 0
src/main/java/com/caimei/entity/WxJsonModel.java

@@ -0,0 +1,96 @@
+package com.caimei.entity;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.Serializable;
+
+public class WxJsonModel implements Serializable {
+	
+	private static final long serialVersionUID = 1L;
+	
+	private String code;  //状态码 1成功 -1失败
+	private String msg;	//提示信息
+	private Object data;		//返回结果
+	
+
+	public static WxJsonModel newInstance() {
+		WxJsonModel jsonModel = new WxJsonModel();
+		return jsonModel.success();
+	}
+
+	public WxJsonModel unLogin() {
+		this.setMsg("请先登录");
+		this.setCode("1002");
+		return this;
+	}
+	
+	public WxJsonModel success(){
+		this.code="1";
+		this.msg="操作成功";
+		return this;
+	}
+	
+	public WxJsonModel success(Object data){
+		this.code="1";
+		this.msg="操作成功";
+		this.data=data;
+		return this;
+	}
+
+	public WxJsonModel success(String msg, Object data){
+		this.code="1";
+		this.msg=msg;
+		this.data=data;
+		return this;
+	}
+
+	public WxJsonModel error(){
+		this.code="-1";
+		this.msg="操作失败";
+		return this;
+	}
+	public WxJsonModel error(String msg){
+		this.code="-1";
+		this.msg=msg;
+		return this;
+	}
+	public WxJsonModel error(String code, String msg){
+		this.code=code;
+		this.msg=msg;
+		return this;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	public Object getData() {
+		return data;
+	}
+
+	public void setData(Object data) {
+		this.data = data;
+	}
+
+	@Override
+	public String toString() {
+		return "WxJsonModel [code=" + code + ", msg=" + msg + ", data=" + data + "]";
+	}
+	
+	public String toJsonString() {
+		return JSONObject.toJSONString(this);
+	}
+	
+}

+ 3 - 0
src/main/resources/application.yml

@@ -0,0 +1,3 @@
+spring:
+  profiles:
+    active: @activatedProperties@

+ 44 - 0
src/main/resources/dev/application-dev.yml

@@ -0,0 +1,44 @@
+server:
+  port: 8107
+spring:
+  application:
+    name: caimei-starstyle #指定服务名
+
+    #数据源连接--start
+  datasource:
+    driverClassName: com.mysql.jdbc.Driver
+    url: jdbc:mysql://192.168.1.11:3306/caimei@20180509?characterEncoding=UTF8
+    username: developer
+    password: 05bZ/OxTB:X+yd%1
+    #数据源连接--end
+
+  #模板引擎配置
+  thymeleaf:
+    #路径
+    prefix: classpath:/templates/
+    #取消thymeleaf对页面的强制校验
+    content-type: text/html
+    mode:  LEGACYHTML5
+    cache: false
+
+#整合mybatis
+mybatis:
+  #加载Mybatis映射文件
+  mapper-locations: classpath:mapper/*Mapper.xml
+  #pojo别名扫描包
+  type-aliases-package: com.caimei.entity
+
+#分页配置
+pagehelper:
+  helperDialect: mysql
+  reasonable: true
+  supportMethodsArguments: true
+  params: count=countSql
+
+#日志配置
+logging:
+  file: E:/brand-alliance/catalina.out
+  level: debug
+
+miniprogramAppId:
+miniprogramAppSecret:

+ 46 - 0
src/main/resources/prod/application-prod.yml

@@ -0,0 +1,46 @@
+server:
+  port: 8107
+spring:
+  application:
+    name: caimei-starstyle #指定服务名
+
+    #数据源连接--start
+  datasource:
+    driverClassName: com.mysql.jdbc.Driver
+    url: jdbc:mysql://10.104.172.219:3306/caimei_newuser?characterEncoding=UTF8
+    username: developer
+    password: diKtPYZ'wToI&9#L
+    #数据源连接--end
+
+  #模板引擎配置
+  thymeleaf:
+    #路径
+    prefix: classpath:/templates/
+    #取消thymeleaf对页面的强制校验
+    content-type: text/html
+    mode:  LEGACYHTML5
+    cache: false
+
+
+#整合mybatis
+mybatis:
+  #加载Mybatis映射文件
+  mapper-locations: classpath:mapper/*Mapper.xml
+  #pojo别名扫描包
+  type-aliases-package: com.caimei.entity
+
+#分页配置
+pagehelper:
+  helperDialect: mysql
+  reasonable: true
+  supportMethodsArguments: true
+  params: count=countSql
+
+
+#日志配置
+logging:
+  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-brand-alliance/catalina.out
+  level: debug
+
+miniprogramAppId:
+miniprogramAppSecret:

+ 23 - 0
src/main/resources/public/index.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<title>采美365网-正品联盟</title>
+<meta charset="UTF-8">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="expires" content="0">
+<meta http-equiv="X-UA-Compatible" content="IE=Edge">
+<meta http-equiv="keywords" content="采美365网-全新概念云端美业线上交易合作平台">
+<meta http-equiv="description" content="采美365网-全新概念云端美业线上交易合作平台">
+<link rel="shortcut icon" href="public/3.0/img/favicon.ico"
+      type="image/x-icon">
+<link rel="stylesheet" href="../public/3.0/css/common/common.css">
+<link rel="stylesheet" href="../html/css/html.css">
+<body>
+<div class="index">
+    欢迎使用!《采美365网-星范商城》
+</div>
+</body>
+<script>
+
+</script>
+</html>

+ 45 - 0
src/main/resources/test/application-test.yml

@@ -0,0 +1,45 @@
+server:
+  port: 8107
+spring:
+  application:
+    name: caimei-starstyle #指定服务名
+
+    #数据源连接--start
+  datasource:
+    driverClassName: com.mysql.jdbc.Driver
+    url: jdbc:mysql://10.104.50.235:3306/caimei?characterEncoding=UTF8
+    username: developer
+    password: J5p";~OVazNl%y)?
+    #数据源连接--end
+
+  #模板引擎配置
+  thymeleaf:
+    #路径
+    prefix: classpath:/templates/
+    #取消thymeleaf对页面的强制校验
+    content-type: text/html
+    mode:  LEGACYHTML5
+    cache: false
+
+
+#整合mybatis
+mybatis:
+  #加载Mybatis映射文件
+  mapper-locations: classpath:mapper/*Mapper.xml
+  #pojo别名扫描包
+  type-aliases-package: com.caimei.entity
+
+#分页配置
+pagehelper:
+  helperDialect: mysql
+  reasonable: true
+  supportMethodsArguments: true
+  params: count=countSql
+
+#日志配置
+logging:
+  file: /mnt/newdatadrive/data/runtime/tomcat-instance/caimei-brand-alliance/catalina.out
+  level: debug
+
+miniprogramAppId:
+miniprogramAppSecret: