Browse Source

resource service complete

huodongdong 7 years ago
parent
commit
e428f275b5
62 changed files with 3225 additions and 55 deletions
  1. 16 3
      pom.xml
  2. 2 2
      rankin-api-web/src/main/java/cn/rankin/apiweb/controller/TestFeignClient.java
  3. 2 2
      rankin-api-web/src/main/java/cn/rankin/apiweb/feign/ProductClient.java
  4. 9 0
      rankin-cms-web/pom.xml
  5. 2 0
      rankin-cms-web/src/main/java/cn/rankin/cmsweb/CmsWebApplication.java
  6. 10 0
      rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/TestController.java
  7. 7 0
      rankin-cms-web/src/main/java/cn/rankin/cmsweb/service/ResourceService.java
  8. 1 1
      rankin-cms-web/src/main/resources/bootstrap.yml
  9. 73 0
      rankin-common-utils/pom.xml
  10. 31 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/annotation/mvc/ApiVerifyLevel.java
  11. 52 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/Cache.java
  12. 35 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APICode.java
  13. 26 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APICodeManager.java
  14. 95 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APIResult.java
  15. 21 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/dto/ResourceSearchDTO.java
  16. 116 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/page/Page.java
  17. 20 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/page/Pageable.java
  18. 21 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/BaseOrderEnum.java
  19. 31 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/BaseStatusEnum.java
  20. 25 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/ItemTypeEnum.java
  21. 49 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/BeanUtil.java
  22. 255 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/DateUtil.java
  23. 80 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/LocalCache.java
  24. 49 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/SecurityUtil.java
  25. 198 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/SnowflakeIdUtil.java
  26. 13 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/UUIDUtil.java
  27. 543 0
      rankin-common-utils/src/main/java/cn/rankin/common/utils/util/ValidateUtils.java
  28. 4 9
      rankin-product-service/src/main/java/cn/rankin/productservice/controller/TestController.java
  29. 52 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Combo.java
  30. 60 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Course.java
  31. 37 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseSubRelation.java
  32. 34 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseSupportRelation.java
  33. 34 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseTagRelation.java
  34. 46 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Item.java
  35. 55 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/ItemPrice.java
  36. 47 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Lesson.java
  37. 34 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/LessonWareRelation.java
  38. 55 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Support.java
  39. 34 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/SupportCircleRelation.java
  40. 49 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Tag.java
  41. 0 27
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Test.java
  42. 46 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Unit.java
  43. 34 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/UnitLessonRelation.java
  44. 55 0
      rankin-product-service/src/main/java/cn/rankin/productservice/entity/Ware.java
  45. 0 2
      rankin-product-service/src/main/java/cn/rankin/productservice/repository/BasicRepository.java
  46. 2 2
      rankin-product-service/src/main/java/cn/rankin/productservice/repository/TestRepository.java
  47. 35 6
      rankin-resource-service/pom.xml
  48. 2 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/ResourceServiceApplication.java
  49. 103 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/AliOSSController.java
  50. 66 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/ResourceController.java
  51. 48 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceAudio.java
  52. 98 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceRemote.java
  53. 54 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceVideo.java
  54. 73 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/entity/Resource.java
  55. 12 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/entity/ResourceType.java
  56. 22 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/proxy/RemoteResourceProxy.java
  57. 12 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/BasicRepository.java
  58. 13 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/ResourceRepository.java
  59. 60 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/ResourceRepositoryImpl.java
  60. 131 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java
  61. 35 0
      rankin-resource-service/src/main/java/cn/rankin/resourceservice/vo/OSSSignature.java
  62. 1 1
      rankin-resource-service/src/main/resources/bootstrap.yml

+ 16 - 3
pom.xml

@@ -3,12 +3,12 @@
 	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>cn.efun</groupId>
+	<groupId>cn.rankin</groupId>
 	<artifactId>rankin</artifactId>
 	<version>0.0.1-SNAPSHOT</version>
-	<packaging>jar</packaging>
+	<packaging>pom</packaging>
 
-	<name>rankin</name>
+	<name>${project.artifactId}</name>
 	<description>Distribute Project Based On Spring Cloud</description>
 
 	<parent>
@@ -35,6 +35,7 @@
         <module>rankin-api-web</module>
         <module>rankin-api-gateway</module>
         <module>rankin-cms-gateway</module>
+        <module>rankin-common-utils</module>
     </modules>
 
 	<dependencies>
@@ -48,6 +49,18 @@
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.38</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.16</version>
+        </dependency>
 	</dependencies>
 
 	<build>

+ 2 - 2
rankin-api-web/src/main/java/cn/rankin/apiweb/controller/TestFeignClient.java

@@ -1,6 +1,6 @@
 package cn.rankin.apiweb.controller;
 
-import cn.rankin.apiweb.feign.ProductClient;
+import cn.rankin.apiweb.service.ProductService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
 public class TestFeignClient {
 
     @Autowired
-    ProductClient productClient;
+    ProductService productClient;
 
     @RequestMapping(value = "/test", method = RequestMethod.GET)
     public String test() {

+ 2 - 2
rankin-api-web/src/main/java/cn/rankin/apiweb/feign/ProductClient.java

@@ -1,10 +1,10 @@
-package cn.rankin.apiweb.feign;
+package cn.rankin.apiweb.service;
 
 import org.springframework.cloud.netflix.feign.FeignClient;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 @FeignClient(name = "${service.product.name}")
-public interface ProductClient {
+public interface ProductService {
 
     @RequestMapping(value = "/hello")
     String hello();

+ 9 - 0
rankin-cms-web/pom.xml

@@ -34,10 +34,19 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-eureka</artifactId>
 		</dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-feign</artifactId>
+        </dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
 		</dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.16</version>
+        </dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>

+ 2 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/CmsWebApplication.java

@@ -2,7 +2,9 @@ package cn.rankin.cmsweb;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 
+@EnableFeignClients
 @SpringBootApplication
 public class CmsWebApplication {
 

+ 10 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/controller/TestController.java

@@ -0,0 +1,10 @@
+package cn.rankin.cmsweb.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class TestController {
+
+}

+ 7 - 0
rankin-cms-web/src/main/java/cn/rankin/cmsweb/service/ResourceService.java

@@ -0,0 +1,7 @@
+package cn.rankin.cmsweb.service;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+
+@FeignClient(name = "${")
+public class ResourceService {
+}

+ 1 - 1
rankin-cms-web/src/main/resources/bootstrap.yml

@@ -5,7 +5,7 @@ spring:
     config:
       uri: http://config.rankin.com:8921
       label: master
-      profile: prod
+      profile: dev
 
 server:
   port: 8500

+ 73 - 0
rankin-common-utils/pom.xml

@@ -0,0 +1,73 @@
+<?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>cn.rankin</groupId>
+	<artifactId>rankin-common-utils</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>${project.artifactId}</name>
+	<description>Common Utils for Spring Boot</description>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+		<java.version>1.8</java.version>
+	</properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.38</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.25</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.16</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <attach>true</attach>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                    <encoding>UTF-8</encoding>
+                    <showWarnings>true</showWarnings>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 31 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/annotation/mvc/ApiVerifyLevel.java

@@ -0,0 +1,31 @@
+package cn.rankin.common.utils.annotation.mvc;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 类名:ApiVerifyLevel  <br />
+ *
+ * 功能:api 接口的 验证拦截力度
+ *
+ * @author tomas
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ApiVerifyLevel {
+
+	public static String NEED_HEADER ="need_header";
+	public static String NEED_TOKEN ="need_token";
+	public static String NEED_NONE ="ignore_all";
+	/**
+     * 功能:参数名 <br/>
+	 *
+	 * @author tomas <br/>
+	 * @version 2017年10月27日 下午4:45:55 <br/>
+	 */
+	String[] level() default NEED_NONE;
+	
+	
+}

+ 52 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/Cache.java

@@ -0,0 +1,52 @@
+package cn.rankin.common.utils.entity;
+
+public class Cache {
+
+    private String key; //缓存ID
+    private Object value; //缓存数据
+    private long validTime; //有效时间
+    private long timeOut; //是否终止
+
+    public Cache() {
+        super();
+    }
+
+    public Cache(String key, Object value, long validTime) {
+        this.key = key;
+        this.value = value;
+        this.timeOut = System.currentTimeMillis() + validTime;
+        this.validTime = validTime;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    public long getTimeOut() {
+        return timeOut;
+    }
+
+    public void setTimeOut(long timeOut) {
+        this.timeOut = timeOut;
+    }
+
+    public long getValidTime() {
+        return validTime;
+    }
+
+    public void setValidTime(long validTime) {
+        this.validTime = validTime;
+    }
+}

+ 35 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APICode.java

@@ -0,0 +1,35 @@
+package cn.rankin.common.utils.entity.api;
+
+import com.alibaba.fastjson.JSON;
+
+public class APICode {
+
+    private int code;
+
+    private String message;
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public APICode() {}
+
+    public APICode(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public static void main(String[] args) {
+        APICode example = new APICode(200, "success");
+        System.out.print(JSON.toJSONString(example));
+    }
+
+}

+ 26 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APICodeManager.java

@@ -0,0 +1,26 @@
+package cn.rankin.common.utils.entity.api;
+
+public class APICodeManager {
+
+    public final static int _C_OK = 200 ;
+    public final static APICode OK = new APICode(_C_OK, null);
+
+    public final static int _C_ACCESS_DENIED = 403;
+    public final static APICode ACCESS_DENIED  = new APICode(_C_ACCESS_DENIED, "访问被拒绝");
+
+    public final static int _C_NOT_FOUND = 404 ;
+    public final static APICode NOT_FOUND = new APICode(_C_NOT_FOUND, "资源不存在");
+
+    public final static int _C_SERVER_ERROR = 500;
+    public final static APICode SERVER_ERROR = new APICode(_C_SERVER_ERROR, "请求处理异常");
+
+    public final static int _C_PARAMETER_ERROR = 400;
+    public final static APICode PARAMETER_ERROR = new APICode(_C_PARAMETER_ERROR, "参数错误");
+
+    public final static int _C_REMOTE_SERVER_ERROR = 600;
+    public final static APICode REMOTE_SERVER_ERROR = new APICode(_C_REMOTE_SERVER_ERROR, "远程服务器错误");
+
+    public final static int _C_ALREADY_EXISTS = 700;
+    public final static APICode ALREADY_EXISTS = new APICode(_C_ALREADY_EXISTS, "数据已存在");
+
+}

+ 95 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/api/APIResult.java

@@ -0,0 +1,95 @@
+package cn.rankin.common.utils.entity.api;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.io.Serializable;
+
+public class APIResult<T> implements Serializable {
+
+    private int code;
+
+    private boolean success = false;
+
+    private String message;
+
+    private T data;
+
+    public APIResult() {
+    }
+
+    public APIResult(APICode apiCode) {
+        this.message = apiCode.getMessage();
+
+        int code = apiCode.getCode();
+        this.code = code;
+
+        if (code == 200) {
+            this.success = true;
+        }
+    }
+
+    private APIResult(APICode apiCode, T data) {
+        this(apiCode);
+        this.data = data;
+    }
+
+    public static APIResult ok() {
+        return new APIResult(APICodeManager.OK);
+    }
+
+    public static APIResult ok(Object value) {
+        return new APIResult(APICodeManager.OK, value);
+    }
+
+    public static APIResult ok(String name, Object value) {
+        return new APIResult(APICodeManager.OK, toMap(name, value));
+    }
+
+    public static APIResult ok(Map<String, Object> data) {
+        return new APIResult(APICodeManager.OK, data);
+    }
+
+    public static APIResult error(APICode apiCode) {
+        return new APIResult(apiCode);
+    }
+
+    public boolean getSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public void setData(T data) {
+        this.data = data;
+    }
+
+    public static <K, V> Map<K, V> toMap(final K k, final V v) {
+        return new HashMap<K, V>() {
+            {
+                this.put(k, v);
+            }
+        };
+    }
+}

+ 21 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/dto/ResourceSearchDTO.java

@@ -0,0 +1,21 @@
+package cn.rankin.common.utils.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class ResourceSearchDTO {
+
+    private String code;
+
+    private String name;
+
+    private Integer type;
+
+    private String sort;
+
+    private Integer by;
+
+    private Integer pageNo = 1;
+
+    private Integer pageSize = 10;
+}

+ 116 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/page/Page.java

@@ -0,0 +1,116 @@
+package cn.rankin.common.utils.entity.page;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.annotation.JSONField;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+
+public class Page<E> implements Pageable<List<E>> ,Serializable {
+
+	// 当前页
+	private int pageNo = 1;
+	
+	// 当前页大小
+	private int pageSize = 10;
+	
+	// 总条数
+	private long totalSize = 0;
+
+	// 数据内容
+	private List<E> list;
+
+	public Page() {
+		// 默认构造方法
+	}
+	
+	public Page(Long totalSize) {
+	    this(totalSize, null, null);
+	}
+	
+	public Page(Long totalSize, Integer pageNo) {
+	    this(totalSize, pageNo, null);
+	}
+	
+	public Page(Long totalSize, Integer pageNo, Integer pageSize) {
+	    if (totalSize != null && totalSize >= 0) {
+	        this.totalSize = totalSize;
+        }
+
+        if (pageNo != null && pageNo > 0) {
+	        this.pageNo = pageNo;
+        }
+
+        if (pageSize != null && pageSize > 0) {
+	        this.pageSize = pageSize;
+        }
+    }
+
+	@Override
+	public int getTotalNo() {
+		if (totalSize == 0 || pageSize == 0) {
+		    return 1;
+        }else {
+		    return (int) ((totalSize / pageSize) + (totalSize % pageSize == 0 ? 0 : 1));
+        }
+	}
+
+	@Override
+	public long getTotalSize() {
+		return totalSize;
+	}
+
+	@Override
+	public int getPageNo() {
+		return pageNo > getTotalNo() ? getTotalNo() : pageNo;
+	}
+
+	@Override
+	public int getPageSize() {
+		return pageSize;
+	}
+
+	@Override
+    @JSONField(name = "hasNext")
+	public boolean hasNext() {
+		return getPageNo() < getTotalNo();
+	}
+
+	@Override
+    @JSONField(name = "hasPrevious")
+	public boolean hasPrevious() {
+		return getPageNo() > 1;
+	}
+
+	public void setPageNo(int pageNo) {
+		this.pageNo = pageNo;
+	}
+
+	public void setPageSize(int pageSize) {
+		this.pageSize = pageSize;
+	}
+
+	public void setTotalSize(int totalSize) {
+		this.totalSize = totalSize;
+	}
+
+	@Override
+	public List<E> getList() {
+		return null == list ? Collections.emptyList() : list;
+	}
+
+	public void setList(List<E> list) {
+	    this.list = list;
+    }
+
+	@Override
+	public long getStart() {
+		return (getPageNo() - 1) * getPageSize();
+	}
+
+//	public static void main(String[] args) {
+//	    Page<Integer> page = new Page(100L, 1, 20);
+//	    System.out.print(JSON.toJSONString(page));
+//    }
+}

+ 20 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/entity/page/Pageable.java

@@ -0,0 +1,20 @@
+package cn.rankin.common.utils.entity.page;
+
+public interface Pageable<E> {
+	
+	E getList();
+
+	int getTotalNo();
+	
+	long getTotalSize();
+
+	int getPageNo();
+	
+	int getPageSize();
+	
+	long getStart();
+	
+	boolean hasNext();
+	
+	boolean hasPrevious();
+}

+ 21 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/BaseOrderEnum.java

@@ -0,0 +1,21 @@
+package cn.rankin.common.utils.enums;
+
+public enum BaseOrderEnum {
+
+    DESC("降序"), ASC("升序");
+
+    private String name;
+
+    BaseOrderEnum(String name) {
+        this.name = name;  
+    }
+      
+    public String getName() {  
+        return name;  
+    }
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+}  

+ 31 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/BaseStatusEnum.java

@@ -0,0 +1,31 @@
+package cn.rankin.common.utils.enums;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public enum BaseStatusEnum {
+
+    NORMAL("正常"),DEL("已删除");
+
+    public static Set<BaseStatusEnum>  show = new HashSet<>();
+
+    static {
+        show.add(BaseStatusEnum.NORMAL);
+    }
+
+    String name;
+
+    BaseStatusEnum( String name) {
+        this.name = name;  
+    }
+      
+    public String getName() {  
+        return name;  
+    }
+
+    @Override
+    public String toString() {
+        return this.name;
+    }
+
+}  

+ 25 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/enums/ItemTypeEnum.java

@@ -0,0 +1,25 @@
+package cn.rankin.common.utils.enums;
+
+public enum ItemTypeEnum {
+
+    COURSE("课程"), SUPPORT("周边");
+
+    private String desc;
+
+    ItemTypeEnum(String desc) {
+        this.desc = desc;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public static ItemTypeEnum getByName(String name) {
+        for (ItemTypeEnum itemType : values()) {
+            if (itemType.name().equals(name)) {
+                return itemType;
+            }
+        }
+        return null;
+    }
+}

+ 49 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/BeanUtil.java

@@ -0,0 +1,49 @@
+package cn.rankin.common.utils.util;
+
+import com.alibaba.fastjson.JSON;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+public class BeanUtil {
+
+    private BeanUtil(){}
+
+    public static Map<String, Object> objectToMap(Object obj) {
+        if(obj == null){
+            return null;
+        }
+
+        Map<String, Object> map = new HashMap<>();
+
+        Field[] declaredFields = obj.getClass().getDeclaredFields();
+        for (Field field : declaredFields) {
+            field.setAccessible(true);
+            try {
+                Object o = field.get(obj);
+                if (Objects.nonNull(o)){
+                    if (o instanceof Collection) {
+                        if (((Collection)o).size()==0){
+                            continue;
+                        }
+                    } else if (o instanceof Map) {
+                        if (((Map) o).size() == 0) {
+                            continue;
+                        }
+                    } else if (o instanceof Enum) {
+                        o = ((Enum) o).name();
+                    }
+                    map.put(field.getName(), o);
+                }
+
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return map;
+    }
+}

+ 255 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/DateUtil.java

@@ -0,0 +1,255 @@
+/**
+ * 文件名:@DateUtil.java <br/>
+ * 包名:cn.efunbox.afw.core.util <br/>
+ * 项目名:afw-core <br/>
+ * @author xtwin <br/>
+ */
+package cn.rankin.common.utils.util;
+
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 类名:DateUtil  <br />
+ *
+ * 功能:
+ *
+ * @author xtwin <br />
+ * 创建时间:2015年12月4日 下午4:44:11  <br />
+ * @version 2015年12月4日
+ */
+public class DateUtil {
+
+	// 缓存
+	private static final Map<String, SimpleDateFormat> formats;
+	
+	static {
+		formats = new HashMap<String, SimpleDateFormat>();
+		
+		formats.put("yyyyMMdd", new SimpleDateFormat("yyyyMMdd"));
+		formats.put("HHmmss", new SimpleDateFormat("HHmmss"));
+		formats.put("yyyyMMddHHmmss", new SimpleDateFormat("yyyyMMddHHmmss"));
+		formats.put("yyyyMMddHHmmssSSS", new SimpleDateFormat("yyyyMMddHHmmssSSS"));
+	}
+	
+	/**
+	 * 
+	 * 功能:比较两个日期的顺序 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-12-28 上午11:20:58 <br/>
+	 */
+	public static int compare(Date one, Date two) {
+		return one.compareTo(two);
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-12-4 下午02:06:59 <br/>
+	 */
+	public static Date add(Date date, int field, int amount) {
+		return add(date, field, amount, null);
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 * field like Calendar.SECOND
+	 * @author xtwin <br/>
+	 * @version 2013-12-4 下午02:06:19 <br/>
+	 */
+	public static Date add(Date date, int field, int amount, TimeZone timeZone) {
+		Calendar cal = (timeZone == null ? Calendar.getInstance() : Calendar.getInstance(timeZone));
+		
+		cal.setTime(date);
+		
+		cal.add(field, amount);
+		
+		return cal.getTime();
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-27 上午10:01:13 <br/>
+	 */
+	public static Date parseDateTime(String source) throws ParseException {
+		return parse(source, "yyyyMMddHHmmss");
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-27 上午10:01:28 <br/>
+	 */
+	public static Date parseTime(String source) throws ParseException {
+		return parse(source, "HHmmss");
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-27 上午10:00:50 <br/>
+	 * @throws ParseException 
+	 */
+	public static Date parseDate(String source) throws ParseException {
+		return parse(source, "yyyyMMdd");
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-27 上午10:00:17 <br/>
+	 */
+	public static Date parse(String source, String pattern) throws ParseException {
+		return getFormat(pattern).parse(source);
+	}
+
+	/**
+	 *
+	 * 功能:获取获取毫秒值得时间戳 + 0-9 随机数一位 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:58:17 <br/>
+	 */
+	public static String getRandomCurrentTimeStamp() {
+		return formaCurrentTimeStamp(new Date())+ new Random().nextInt(9);
+	}
+	/**
+	 *
+	 * 功能:获取秒值得时间戳 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:58:17 <br/>
+	 */
+	public static String getTimeStamp() {
+		return formatDateTime(new Date());
+	}
+	/**
+	 *
+	 * 功能: 获取毫秒值得时间戳 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:58:17 <br/>
+	 */
+	public static String getCurrentTimeStamp() {
+		return formaCurrentTimeStamp(new Date());
+	}
+	/**
+	 *
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:58:17 <br/>
+	 */
+	public static String formaCurrentTimeStamp(Date date) {
+		return format(date, "yyyyMMddHHmmssSSS");
+	}
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:58:17 <br/>
+	 */
+	public static String formatDateTime(Date date) {
+		return format(date, "yyyyMMddHHmmss");
+	}
+	
+	/**
+	 * 
+	 * 功能:按默认规则格式化为时间 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:57:33 <br/>
+	 */
+	public static String formatTime(Date date) {
+		return format(date, "HHmmss");
+	}
+	
+	/**
+	 * 
+	 * 功能:按默认规则格式化日期 <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:56:47 <br/>
+	 */
+	public static String formatDate(Date date) {
+		return format(date, "yyyyMMdd");
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-26 下午07:55:49 <br/>
+	 */
+	public static String format(Date date, String pattern) {
+		return getFormat(pattern).format(date);
+	}
+	
+	/**
+	 * 
+	 * 功能: <br/>
+	 *
+	 * @author xtwin <br/>
+	 * @version 2013-11-27 上午09:59:37 <br/>
+	 */
+	private static SimpleDateFormat getFormat(String pattern) {
+		SimpleDateFormat sdf = formats.get(pattern);
+		
+		if (null == sdf) {
+			formats.put(pattern, sdf = new SimpleDateFormat(pattern));
+		}
+		
+		// 强制格式匹配
+		sdf.setLenient(false);
+		
+		return sdf;
+	}
+
+	/**
+	 * 将短时间格式时间转换为字符串 yyyy-MM-dd
+	 *
+	 * @param dateDate
+	 * @return
+	 */
+	public static String dateToStr(Date dateDate) {
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+		String dateString = formatter.format(dateDate);
+		return dateString;
+	}
+
+	/**
+	 * 将短时间格式字符串转换为时间 yyyy-MM-dd
+	 *
+	 * @param strDate
+	 * @return
+	 */
+	public static Date strToDate(String strDate) {
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+		ParsePosition pos = new ParsePosition(0);
+		Date strtodate = formatter.parse(strDate, pos);
+		return strtodate;
+	}
+
+	public static void main(String[] args) {
+		for (int i = 0; i < 20; i++) {
+			System.out.println(DateUtil.getRandomCurrentTimeStamp());
+		}
+	}
+}

+ 80 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/LocalCache.java

@@ -0,0 +1,80 @@
+package cn.rankin.common.utils.util;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import cn.rankin.common.utils.entity.Cache;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class LocalCache {
+
+    private static final long interval = 5 * 60 * 1000;
+
+    private static final long timeout = 5 * 60 * 1000;
+
+    private static Map<Object, Cache> pool = new ConcurrentHashMap<Object, Cache>();
+
+    private static final Logger log = LoggerFactory.getLogger(LocalCache.class);
+
+
+    // Create a timer to clean cache
+	static {
+
+		new Timer().schedule(new TimerTask() {
+			@Override
+			public void run() {
+				for (Iterator<Object> it = LocalCache.pool.keySet().iterator(); it.hasNext();) {
+					Object key = it.next();
+					Cache cache = LocalCache.pool.get(key);
+					if (null != cache && cache.getTimeOut() < System.currentTimeMillis()) {
+						LocalCache.pool.remove(key);
+						cache = null;
+                        log.info("LocalCache remove key: {}", key);
+					}
+				}
+			}
+		}, new Date(), interval);
+	}
+
+	// timeout: seconds
+	public static void add(String key, Object value, int timeout) {
+		Cache cache = new Cache(key, value, timeout*1000L);
+		pool.put(key, cache);
+	}
+
+	public static void add(String key, Object value) {
+	    Cache cache = new Cache(key, value, timeout);
+	    pool.put(key, cache);
+    }
+
+	public static Object get(String key, boolean expire) {
+
+		Cache cache = pool.get(key);
+		if (null == cache) {
+		    return null;
+        }
+
+        // not strict to expire
+        if (expire == false) {
+		    return cache.getValue();
+        }
+
+		if (cache.getTimeOut() < System.currentTimeMillis()) {
+			pool.remove(key);
+			return null;
+		}
+
+		return cache.getValue();
+	}
+
+	public static void main(String[] args) throws Exception {
+		LocalCache.add("a", "A", 1); //保存3秒
+		LocalCache.add("b", "B", 1); //保存3秒
+        while (true) {
+			Thread.sleep(900);
+			System.out.println(LocalCache.get("b", false));
+            System.out.println(LocalCache.get("a", false));
+		}
+	}
+}

+ 49 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/SecurityUtil.java

@@ -0,0 +1,49 @@
+package cn.rankin.common.utils.util;
+
+import java.security.MessageDigest;
+
+public class SecurityUtil {
+
+    public static String MD5(String value) {
+
+        StringBuilder out = new StringBuilder();
+
+        try {
+            StringBuilder in = new StringBuilder(value);
+
+            MessageDigest md5 = MessageDigest.getInstance("MD5");
+            md5.update(in.toString().getBytes("UTF8"));
+
+            byte s[] = md5.digest();
+            for (int i = 0; i < s.length; i++) {
+                String tmp = Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6);
+                out.append(tmp);
+            }
+        } catch (Exception e) {
+            return null;
+        }
+
+        return out.toString();
+    }
+
+    public static String MD5(String value, String salt) {
+        if (salt != null && value != null) {
+            return MD5(value + salt);
+        }else {
+            return MD5(value);
+        }
+    }
+
+    /**
+     * 测试程序
+     *
+     * @param args String[]
+     */
+    public static void main(String[] args) {
+        StringBuilder out = new StringBuilder();
+        System.out.println(out.toString());
+        System.out.println(SecurityUtil.MD5("123456", null).equals("e10adc3949ba59abbe56e057f20f883e"));
+        System.out.println(SecurityUtil.MD5("bcd"));
+        System.out.println(SecurityUtil.MD5("123456"));
+    }
+}

+ 198 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/SnowflakeIdUtil.java

@@ -0,0 +1,198 @@
+package cn.rankin.common.utils.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Twitter_Snowflake<br>
+ * SnowFlake的结构如下(每部分用-分开):<br>
+ * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
+ * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
+ * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
+ * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
+ * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
+ * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
+ * 加起来刚好64位,为一个Long型。<br>
+ * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
+ */
+public class SnowflakeIdUtil {
+
+    private static volatile SnowflakeIdUtil singleton = null;
+    // ==============================Fields===========================================
+    /** 开始时间截 (2015-01-01) */
+    private final long twepoch = 1420041600000L;
+
+    /** 机器id所占的位数 */
+    private final long workerIdBits = 5L;
+
+    /** 数据标识id所占的位数 */
+    private final long datacenterIdBits = 5L;
+
+    /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
+    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
+
+    /** 支持的最大数据标识id,结果是31 */
+    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+
+    /** 序列在id中占的位数 */
+    private final long sequenceBits = 12L;
+
+    /** 机器ID向左移12位 */
+    private final long workerIdShift = sequenceBits;
+
+    /** 数据标识id向左移17位(12+5) */
+    private final long datacenterIdShift = sequenceBits + workerIdBits;
+
+    /** 时间截向左移22位(5+5+12) */
+    private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
+    private final long sequenceMask = -1L ^ (-1L << sequenceBits);
+
+    /** 工作机器ID(0~31) */
+    private long workerId=1L;
+
+    /** 数据中心ID(0~31) */
+    private long datacenterId=1L;
+
+    /** 毫秒内序列(0~4095) */
+    private long sequence = 0L;
+
+    /** 上次生成ID的时间截 */
+    private long lastTimestamp = -1L;
+
+
+
+    //==============================Constructors=====================================
+    private SnowflakeIdUtil(){}
+    /**
+     * 构造函数
+     */
+    public static SnowflakeIdUtil getSnowflakeIdUtil(){
+        if(singleton == null){
+            synchronized (SnowflakeIdUtil.class){
+                if(singleton == null){
+                    singleton = new SnowflakeIdUtil(0,0);
+                }
+            }
+        }
+        return singleton;
+    }
+    public static SnowflakeIdUtil getSnowflakeIdUtil(long workerId, long datacenterId){
+        if(singleton == null){
+            synchronized (SnowflakeIdUtil.class){
+                if(singleton == null){
+                    singleton = new SnowflakeIdUtil(workerId,datacenterId);
+                }
+            }
+        }
+        return singleton;
+    }
+    /**
+     * 构造函数
+     * @param workerId 工作ID (0~31)
+     * @param datacenterId 数据中心ID (0~31)
+     */
+    public SnowflakeIdUtil(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+
+    // ==============================Methods==========================================
+    /**
+     * 获得下一个ID (该方法是线程安全的)
+     * @return SnowflakeId
+     */
+    public synchronized long nextId() {
+        long timestamp = timeGen();
+
+        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException(
+                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+        }
+
+        //如果是同一时间生成的,则进行毫秒内序列
+        if (lastTimestamp == timestamp) {
+            sequence = (sequence + 1) & sequenceMask;
+            //毫秒内序列溢出
+            if (sequence == 0) {
+                //阻塞到下一个毫秒,获得新的时间戳
+                timestamp = tilNextMillis(lastTimestamp);
+            }
+        }
+        //时间戳改变,毫秒内序列重置
+        else {
+            sequence = 0L;
+        }
+        //上次生成ID的时间截
+        lastTimestamp = timestamp;
+
+       /* //移位并通过或运算拼到一起组成64位的ID
+        return ((timestamp - twepoch) << timestampLeftShift) //
+                | (datacenterId << datacenterIdShift) //
+                | (workerId << workerIdShift) //
+                | sequence;*/
+
+        // modify by tomas 2017-08-28
+        try {
+            Thread.sleep(1);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        return  Long.parseLong(timestamp+ getNewAppend() );
+    }
+
+    protected String getNewAppend() {
+        StringBuilder stringBuilder=new StringBuilder((System.nanoTime() + "").substring(7, 10));
+        return  stringBuilder.toString();
+
+    }
+    /**
+     * 阻塞到下一个毫秒,直到获得新的时间戳
+     * @param lastTimestamp 上次生成ID的时间截
+     * @return 当前时间戳
+     */
+    protected long tilNextMillis(long lastTimestamp) {
+        long timestamp = timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = timeGen();
+        }
+        return timestamp;
+    }
+
+    /**
+     * 返回字符串类型 code
+     * @return
+     */
+    public String nextCode() {
+        return  String.valueOf(nextId());
+    }
+    /**
+     * 返回以毫秒为单位的当前时间
+     * @return 当前时间(毫秒)
+     */
+    protected long timeGen() {
+        return System.currentTimeMillis();
+    }
+
+
+    public static void main(String[] args) throws Exception{
+
+        Set<Long> ids= new HashSet<>();
+        long start=System.currentTimeMillis();
+        for (int j=0 ;j<1000;j++){
+            long id = SnowflakeIdUtil.getSnowflakeIdUtil().nextId();
+            ids.add(id);
+            //System.out.println(id);
+        }
+        System.out.println(ids.size()+"---time="+ (System.currentTimeMillis()-start));
+
+    }
+}

+ 13 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/UUIDUtil.java

@@ -0,0 +1,13 @@
+package cn.rankin.common.utils.util;
+
+import java.util.UUID;
+
+public class UUIDUtil {
+
+    public static String getUUID() {
+        UUID uuid = UUID.randomUUID();
+        String str = uuid.toString();
+        str = str.replace("-", "");
+        return str;
+    }
+}

File diff suppressed because it is too large
+ 543 - 0
rankin-common-utils/src/main/java/cn/rankin/common/utils/util/ValidateUtils.java


+ 4 - 9
rankin-product-service/src/main/java/cn/rankin/productservice/controller/TestController.java

@@ -1,7 +1,7 @@
 package cn.rankin.productservice.controller;
 
-import cn.rankin.productservice.entity.Test;
-import cn.rankin.productservice.repository.TestRepository;
+import cn.rankin.productservice.entity.Ware;
+import cn.rankin.productservice.repository.WareRepository;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -11,16 +11,11 @@ import org.springframework.web.bind.annotation.RestController;
 public class TestController {
 
     @Autowired
-    private TestRepository testRepository;
+    private WareRepository testRepository;
 
     @RequestMapping(value = "/hello", method = RequestMethod.GET)
     public String sayHello() {
-        Test test = new Test();
-        test.setId(123L);
-        test.setName("huodongdong");
-        test.setAge(12);
-        test.setAddress("beijing");
-        testRepository.save(test);
+        Ware ware = new Ware();
         return "hello!";
     }
 }

+ 52 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Combo.java

@@ -0,0 +1,52 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_combo")
+@DynamicInsert
+@DynamicUpdate
+public class Combo implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column(name = "merchant_id")
+    private Long merchantId;
+
+    @Column
+    private String name;
+
+    @Column
+    private String digest;
+
+    @Column(name = "cv_img_ids")
+    private String cvImgIds;
+
+    @Column(name = "dis_price")
+    private Double disPrice;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created")
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 60 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Course.java

@@ -0,0 +1,60 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.validator.constraints.Range;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_course")
+@DynamicInsert
+@DynamicUpdate
+public class Course implements Serializable{
+
+    @Id
+    private Long id;
+
+    @Column(nullable = false, unique = true)
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private String title;
+
+    @Column
+    private String digest;
+
+    @Column
+    private String detail;
+
+    @Column
+    private String keyword;
+
+    @Column(name = "cv_img_ids")
+    private String cvImgIds;
+
+    @Column(name = "bg_img_ids")
+    private String bgImgIds;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Date gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Date gmtModified;
+
+}

+ 37 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseSubRelation.java

@@ -0,0 +1,37 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_course_sub_relation")
+@DynamicInsert
+@DynamicUpdate
+public class CourseSubRelation implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column(name = "course_code")
+    private String courseCode;
+
+    @Column(name = "sub_code")
+    private String subCode;
+
+    @Column
+    private Integer type;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+}

+ 34 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseSupportRelation.java

@@ -0,0 +1,34 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_course_support_relation")
+@DynamicInsert
+@DynamicUpdate
+public class CourseSupportRelation implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column(name = "course_code")
+    private String courseCode;
+
+    @Column(name = "support_code")
+    private String supportCode;
+
+    @Column(name = "gmt_created", insertable = false, updatable = false)
+    private Timestamp gmtCreated;
+}

+ 34 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/CourseTagRelation.java

@@ -0,0 +1,34 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_course_tag_relation")
+@DynamicInsert
+@DynamicUpdate
+public class CourseTagRelation implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column(name = "tag_code")
+    private String tagCode;
+
+    @Column(name = "course_code")
+    private String courseCode;
+
+    @Column(name = "gmt_created", insertable = false, updatable = false)
+    private Timestamp gmtCreated;
+}

+ 46 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Item.java

@@ -0,0 +1,46 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_item")
+@DynamicInsert
+@DynamicUpdate
+public class Item implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column
+    private String code;
+
+    @Column
+    private Integer type;
+
+    @Column(name = "merchant_id")
+    private Long merchantId;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 55 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/ItemPrice.java

@@ -0,0 +1,55 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_item_price")
+@DynamicInsert
+@DynamicUpdate
+public class ItemPrice implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column
+    private String name;
+
+    @Column(name = "item_id")
+    private Long itemId;
+
+    @Column
+    private Integer type;
+
+    @Column
+    private Integer duration;
+
+    @Column(name = "cp_price")
+    private Double cpPrice;
+
+    @Column(name = "mr_price")
+    private Double mrPrice;
+
+    @Column(name = "tr_price")
+    private Double trPrice;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 47 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Lesson.java

@@ -0,0 +1,47 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.validator.constraints.Range;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_lesson")
+@DynamicInsert
+@DynamicUpdate
+public class Lesson implements Serializable {
+    @Id
+    private Long id;
+
+    @Column(nullable = false, unique = true)
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private String digest;
+
+    @Column
+    @Range(min = 0, max = 100)
+    private Integer type;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 34 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/LessonWareRelation.java

@@ -0,0 +1,34 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_lesson_ware_relation")
+@DynamicInsert
+@DynamicUpdate
+public class LessonWareRelation implements Serializable{
+
+    @Id
+    private Long id;
+
+    @Column(name = "lesson_code")
+    private String lessonCode;
+
+    @Column(name = "ware_code")
+    private String wareCode;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+}

+ 55 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Support.java

@@ -0,0 +1,55 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_support")
+@DynamicInsert
+@DynamicUpdate
+public class Support implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private String title;
+
+    @Column
+    private Integer type;
+
+    @Column
+    private String digest;
+
+    @Column
+    private String detail;
+
+    @Column(name = "img_ids")
+    private String imgIds;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", insertable = false, updatable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 34 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/SupportCircleRelation.java

@@ -0,0 +1,34 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_circle_relation")
+@DynamicInsert
+@DynamicUpdate
+public class SupportCircleRelation implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column
+    private String fcode;
+
+    @Column
+    private String tcode;
+
+    @Column(name = "gmt_created", insertable = false, updatable = false)
+    private Timestamp gmtCreated;
+}

+ 49 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Tag.java

@@ -0,0 +1,49 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_tag")
+@DynamicInsert
+@DynamicUpdate
+public class Tag implements Serializable {
+
+    @Id
+    private Long id;
+
+    @Column
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private Integer type;
+
+    @Column(name = "merchant_id")
+    private Long merchantId;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 0 - 27
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Test.java

@@ -1,27 +0,0 @@
-package cn.rankin.productservice.entity;
-
-import lombok.Data;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import java.io.Serializable;
-
-@Data
-@Entity
-public class Test implements Serializable{
-
-    @Id
-    private Long id;
-
-    @Column(name = "name")
-    private String name;
-
-    @Column(name = "age")
-    private Integer age;
-
-    @Column(name = "address")
-    private String address;
-
-}

+ 46 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Unit.java

@@ -0,0 +1,46 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_unit")
+@DynamicInsert
+@DynamicUpdate
+public class Unit implements Serializable{
+
+    @Id
+    private Long id;
+
+    @Column
+    private String code;
+
+    @Column
+    private  String name;
+
+    @Column
+    private String digest;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+}

+ 34 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/UnitLessonRelation.java

@@ -0,0 +1,34 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_unit_lesson_relation")
+@DynamicInsert
+@DynamicUpdate
+public class UnitLessonRelation implements Serializable{
+
+    @Id
+    private Long id;
+
+    @Column(name = "unit_code")
+    private String unitCode;
+
+    @Column(name = "lesson_code")
+    private String lessonCode;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+}

+ 55 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/entity/Ware.java

@@ -0,0 +1,55 @@
+package cn.rankin.productservice.entity;
+
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.hibernate.validator.constraints.Range;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_ware")
+@DynamicInsert
+@DynamicUpdate
+public class Ware implements Serializable{
+
+    @Id
+    private Long id;
+
+    @Column(nullable = false, unique = true)
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private String digest;
+
+    @Column
+    @Range(min = 0, max = 100)
+    private Integer type;
+
+    @Column(name = "play_url")
+    private String playUrl;
+
+    @Column(name = "img_ids")
+    private String imgIds;
+
+    @Column
+    private Integer sort;
+
+    @Column
+    private Integer status;
+
+    @Column(name = "gmt_created", updatable = false, insertable = false)
+    private Timestamp gmtCreated;
+
+    @Column(name = "gmt_modified")
+    private Timestamp gmtModified;
+
+}

+ 0 - 2
rankin-product-service/src/main/java/cn/rankin/productservice/repository/BasicRepository.java

@@ -1,8 +1,6 @@
 package cn.rankin.productservice.repository;
 
 import java.io.Serializable;
-import java.util.List;
-import org.springframework.data.domain.Sort;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.repository.NoRepositoryBean;
 

+ 2 - 2
rankin-product-service/src/main/java/cn/rankin/productservice/repository/TestRepository.java

@@ -1,9 +1,9 @@
 package cn.rankin.productservice.repository;
 
-import cn.rankin.productservice.entity.Test;
+import cn.rankin.productservice.entity.Ware;
 import org.springframework.stereotype.Repository;
 
 @Repository
-public interface TestRepository extends BasicRepository<Test, Long> {
+public interface WareRepository extends BasicRepository<Ware, Long> {
 
 }

+ 35 - 6
rankin-resource-service/pom.xml

@@ -11,12 +11,12 @@
 	<name>rankin-resource-service</name>
 	<description>Resource Service For Spring Cloud</description>
 
-	<parent>
-		<groupId>org.springframework.boot</groupId>
-		<artifactId>spring-boot-starter-parent</artifactId>
-		<version>1.5.8.RELEASE</version>
-		<relativePath/> <!-- lookup parent from repository -->
-	</parent>
+    <parent>
+        <groupId>cn.rankin</groupId>
+        <artifactId>rankin</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
 
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -34,6 +34,35 @@
 			<groupId>org.springframework.cloud</groupId>
 			<artifactId>spring-cloud-starter-eureka</artifactId>
 		</dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-feign</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>2.2.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.16.16</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.rankin</groupId>
+            <artifactId>rankin-common-utils</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>

+ 2 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/ResourceServiceApplication.java

@@ -2,7 +2,9 @@ package cn.rankin.resourceservice;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
 
+@EnableFeignClients
 @SpringBootApplication
 public class ResourceServiceApplication {
 

+ 103 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/AliOSSController.java

@@ -0,0 +1,103 @@
+package cn.rankin.resourceservice.controller;
+
+import cn.rankin.common.utils.entity.api.APICodeManager;
+import cn.rankin.common.utils.entity.api.APIResult;
+import cn.rankin.resourceservice.vo.OSSSignature;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.common.utils.BinaryUtil;
+import com.aliyun.oss.model.MatchMode;
+import com.aliyun.oss.model.PolicyConditions;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.sql.Date;
+
+@Slf4j
+@RestController
+@RequestMapping(value = "oss")
+public class AliOSSController {
+
+    @Value("${ali.oss.endpoint}")
+    private String endpoint;
+
+    @Value("${ali.oss.accessKeyId}")
+    private String accessId;
+
+    @Value("${ali.oss.accessKeySecret}")
+    private String accessKey;
+
+    @Value("${ali.oss.bucket}")
+    private String bucket;
+
+    @Value("${ali.oss.rankin.dir}")
+    private String dir;
+
+    public String getHost() {
+        return  "http://" + bucket + "." + endpoint;
+    }
+
+    private final static long expireTime = 2 * 60;
+
+    @RequestMapping(value = "signature", method = RequestMethod.GET)
+    public APIResult<OSSSignature> getSignature (String fileName) {
+        String path = getPath(fileName);
+        if (path == null || path.length() == 0) {
+            return APIResult.error(APICodeManager.PARAMETER_ERROR);
+        }
+
+        OSSSignature signature = new OSSSignature(accessId, dir);
+        signature.setPath(path);
+        signature.setHost(getHost());
+
+        try {
+            OSSClient client = new OSSClient(endpoint, accessId, accessKey);
+
+            long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
+            signature.setExpire(String.valueOf(expireEndTime / 1000));
+
+            // generate policy
+            PolicyConditions policyConds = new PolicyConditions();
+            policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
+            policyConds.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
+            String postPolicy = client.generatePostPolicy(new Date(expireEndTime), policyConds);
+            byte[] binaryData = postPolicy.getBytes("utf-8");
+            String encodedPolicy = BinaryUtil.toBase64String(binaryData);
+
+            signature.setPolicy(encodedPolicy);
+
+            String postSignature = client.calculatePostSignature(postPolicy);
+            signature.setSignature(postSignature);
+
+        }catch (Exception e) {
+            log.error("OSS Signature error: {}", e);
+            return APIResult.error(APICodeManager.SERVER_ERROR);
+        }
+
+        return APIResult.ok(signature);
+    }
+
+    public static String getPath(String fileName) {
+        String path;
+        if (fileName == null || fileName.length() == 0) {
+            return null;
+        }
+
+        if (fileName.indexOf("-") != -1) {
+            path = fileName.replaceAll("-","/");
+        }else {
+            path = fileName;
+        }
+
+        int dotPos = path.indexOf(".");
+        if (dotPos > -1) {
+            String suffix = path.substring(dotPos);
+            path = path.replace(suffix, suffix.toLowerCase());
+        }
+
+        return path;
+    }
+}
+

+ 66 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/controller/ResourceController.java

@@ -0,0 +1,66 @@
+package cn.rankin.resourceservice.controller;
+
+import cn.rankin.common.utils.entity.api.APICodeManager;
+import cn.rankin.common.utils.entity.api.APIResult;
+import cn.rankin.common.utils.entity.page.Page;
+import cn.rankin.common.utils.entity.dto.ResourceSearchDTO;
+import cn.rankin.common.utils.util.UUIDUtil;
+import cn.rankin.resourceservice.entity.Resource;
+import cn.rankin.resourceservice.entity.ResourceType;
+import cn.rankin.resourceservice.service.ResourceService;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping(value = "resource")
+public class ResourceController {
+
+    @Autowired
+    private ResourceService resourceService;
+
+    @RequestMapping(value = "/list")
+    public APIResult<Page<Resource>> search(ResourceSearchDTO searchDTO) {
+        log.info(JSON.toJSONString(searchDTO));
+
+        // 参数错误返回
+        if (searchDTO == null || searchDTO.getType() == null) {
+            return APIResult.error(APICodeManager.PARAMETER_ERROR);
+        }
+
+        Integer type = searchDTO.getType();
+        if (type.intValue() == ResourceType.IMG) {
+            // 图片本地取
+            return resourceService.search(searchDTO.getCode(), searchDTO.getName(), searchDTO.getSort(), searchDTO.getPageNo(), searchDTO.getPageSize());
+        }else {
+            // 其他去云平台
+            if (searchDTO.getCode() != null) {
+                return resourceService.findRemoteByCode(searchDTO.getCode());
+            }else {
+                resourceService.testAPI();
+                return resourceService.findRemotePage(searchDTO);
+            }
+        }
+    }
+
+    @RequestMapping(method = RequestMethod.POST)
+    public APIResult<Resource> create(@RequestBody Resource resource) {
+        if (!resource.isRight() || resource.getId() != null) {
+            return APIResult.error(APICodeManager.PARAMETER_ERROR);
+        }
+
+        if (resourceService.exists(resource.getCode())) {
+            return APIResult.error(APICodeManager.ALREADY_EXISTS);
+        }
+
+        resource.setId(UUIDUtil.getUUID());
+        Resource result = resourceService.save(resource);
+
+        return APIResult.ok(result);
+    }
+}

+ 48 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceAudio.java

@@ -0,0 +1,48 @@
+package cn.rankin.resourceservice.dto;
+
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@ToString
+public class ResourceAudio implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 主键 uuid
+    private String id;
+
+    // 关联资源id
+    private String rid;
+
+    // oss bucket名
+    private String bucket;
+
+    // oss路径
+    private String path;
+
+    // 格式,{mp3,,,,}
+    private String format;
+
+    // 类型
+    private Long size;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date createTime;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date updateTime;
+
+    //表示状态,取值{0,1}, 分别表示{'正常状态','已删除'}
+    @Enumerated(EnumType.ORDINAL)
+    private BaseStatusEnum status = BaseStatusEnum.NORMAL;
+
+    private String fullPath;
+
+}

+ 98 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceRemote.java

@@ -0,0 +1,98 @@
+package cn.rankin.resourceservice.dto;
+
+import java.io.Serializable;
+import java.util.*;
+import javax.persistence.*;
+
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import cn.rankin.resourceservice.entity.Resource;
+import cn.rankin.resourceservice.entity.ResourceType;
+import lombok.Data;
+
+@Data
+public class ResourceRemote implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 主键 uuid
+    private String id;
+
+    // 资源编号
+    private String no;
+
+    // 名称
+    private String title;
+
+    // 类型
+    private Integer type;
+
+    private Date createTime;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date updateTime;
+
+    //表示状态,取值{0,1}, 分别表示{'正常状态','已删除'}
+    @Enumerated(EnumType.ORDINAL)
+    private BaseStatusEnum status = BaseStatusEnum.NORMAL;
+
+    @Transient
+    private Set<ResourceVideo> videos = new HashSet<ResourceVideo>();
+
+    @Transient
+    private Set<ResourceAudio> audios = new HashSet<ResourceAudio>();
+
+    public List<Resource> toNativeResource() {
+        if (type == null) {
+            return new ArrayList<>();
+        }
+
+        if (type.intValue() == ResourceType.AUDIO) {
+            return toNativeAudio();
+        }else if (type.intValue() == ResourceType.VIDEO) {
+            return toNativeVideo();
+        }
+
+        return new ArrayList<>();
+    }
+
+    public List<Resource> toNativeVideo() {
+        List<Resource> resourceList = new ArrayList<>();
+        videos.forEach(v -> {
+            Resource resource = new Resource();
+            resource.setId(v.getId());
+            resource.setCode(no);
+            resource.setName(title);
+            resource.setType(type);
+            resource.setUrl(v.getFullPath());
+            resource.setFormat(v.getFormat());
+            resource.setQuality(v.getQuality());
+            resource.setSize(v.getSize());
+            resource.setPath(v.getPath());
+            resource.setStatus(v.getStatus());
+            resource.setGmtCreated(v.getCreateTime());
+            resource.setGmtModified(v.getUpdateTime());
+            resourceList.add(resource);
+        });
+        return resourceList;
+    }
+
+    public List<Resource> toNativeAudio() {
+        List<Resource> resourceList = new ArrayList<>();
+        audios.forEach(v -> {
+            Resource resource = new Resource();
+            resource.setId(v.getId());
+            resource.setCode(no);
+            resource.setName(title);
+            resource.setType(type);
+            resource.setUrl(v.getFullPath());
+            resource.setFormat(v.getFormat());
+            resource.setSize(v.getSize());
+            resource.setPath(v.getPath());
+            resource.setStatus(v.getStatus());
+            resource.setGmtCreated(v.getCreateTime());
+            resource.setGmtModified(v.getUpdateTime());
+            resourceList.add(resource);
+        });
+        return resourceList;
+    }
+}

+ 54 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/dto/ResourceVideo.java

@@ -0,0 +1,54 @@
+package cn.rankin.resourceservice.dto;
+
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+
+@Data
+@ToString
+public class ResourceVideo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    // 主键 uuid
+    private String id;
+
+    // 关联资源id
+    private String rid;
+
+    // oss bucket名
+    private String bucket;
+
+    // oss路径
+    private String path;
+
+    // 格式,目前可取两个值{mp4, m3u8}
+    private String format;
+
+    // 清晰度, {fluent, standard, high, superclear}
+    private String quality;
+
+    // 类型
+    private Integer dataRate;
+    // 类型
+    private Long size;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date createTime;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date updateTime;
+
+    //表示状态,取值{0,1}, 分别表示{'正常状态','已删除'}
+    @Enumerated(EnumType.ORDINAL)
+    private BaseStatusEnum status = BaseStatusEnum.NORMAL;
+
+    @Transient
+    private String fullPath;
+
+}

+ 73 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/entity/Resource.java

@@ -0,0 +1,73 @@
+package cn.rankin.resourceservice.entity;
+
+import cn.rankin.common.utils.enums.BaseStatusEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+import lombok.ToString;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@ToString
+@Entity
+@Table(name = "lj_resource")
+@DynamicInsert
+@DynamicUpdate
+public class Resource implements Serializable {
+
+    @Id
+    private String id;
+
+    @Column
+    private String code;
+
+    @Column
+    private String name;
+
+    @Column
+    private Integer type;
+
+    @Column
+    private String format;
+
+    @Column
+    private String quality;
+
+    @Column
+    private Long size;
+
+    @Column
+    private String path;
+
+    @Column
+    @Enumerated(EnumType.ORDINAL)
+    private BaseStatusEnum status;
+
+    @Column(name = "gmt_created")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date gmtCreated;
+
+    @Column(name = "gmt_modified")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date gmtModified;
+
+    @Transient
+    private String url;
+
+    @JsonIgnore
+    public boolean isRight() {
+        if (code == null || code.length() == 0) {
+            return false;
+        }
+
+        if (path == null || path.length() == 0) {
+            return false;
+        }
+
+        return true;
+    }
+}

+ 12 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/entity/ResourceType.java

@@ -0,0 +1,12 @@
+package cn.rankin.resourceservice.entity;
+
+public class ResourceType {
+
+    public final static int VIDEO = 0;
+
+    public final static int AUDIO = 1;
+
+    public final static int LIVE = 2;
+
+    public final static int IMG = 3;
+}

+ 22 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/proxy/RemoteResourceProxy.java

@@ -0,0 +1,22 @@
+package cn.rankin.resourceservice.proxy;
+
+import cn.rankin.common.utils.entity.api.APIResult;
+import cn.rankin.common.utils.entity.page.Page;
+import cn.rankin.resourceservice.dto.ResourceRemote;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.Map;
+
+@FeignClient(value = "remote-resource", url = "${remote.resource.url}")
+public interface RemoteResourceProxy {
+
+    @RequestMapping(value = "rcenter/v1/resources/page", method = RequestMethod.GET)
+    APIResult<Page<ResourceRemote>> findPage(@RequestParam Map<String, Object> map);
+
+    @RequestMapping(value = "rcenter/v1/resources/no/{code}", method = RequestMethod.GET)
+    APIResult<ResourceRemote> findByCode(@PathVariable("code") String code);
+}

+ 12 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/BasicRepository.java

@@ -0,0 +1,12 @@
+package cn.rankin.resourceservice.repository;
+
+import cn.rankin.resourceservice.entity.Resource;
+import java.util.List;
+
+public interface BasicRepository {
+
+    Long count(String code, String name);
+
+    List<Resource> search(String code, String name, String sort, Long start, Integer pageSize);
+
+}

+ 13 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/ResourceRepository.java

@@ -0,0 +1,13 @@
+package cn.rankin.resourceservice.repository;
+
+import cn.rankin.resourceservice.entity.Resource;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ResourceRepository extends JpaRepository<Resource, Long>, BasicRepository {
+
+    Long countByCode(String code);
+
+}

+ 60 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/repository/ResourceRepositoryImpl.java

@@ -0,0 +1,60 @@
+package cn.rankin.resourceservice.repository;
+
+import cn.rankin.common.utils.entity.page.Page;
+import cn.rankin.resourceservice.entity.Resource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.List;
+
+public class ResourceRepositoryImpl implements BasicRepository{
+
+    private static final String TABLE = "lj_resource";
+
+    @PersistenceContext
+    private EntityManager em;
+
+    public List<Resource> search(String code, String name, String sort, Long start, Integer pageSize) {
+
+        StringBuilder buf = new StringBuilder(String.format("SELECT * FROM %s WHERE 1=1", TABLE));
+
+        if (code != null && code.length() > 0) {
+            buf.append(String.format(" AND code LIKE '%%%s%%'", code));
+        }
+
+        if (name != null && name.length() > 0) {
+            buf.append(String.format(" AND name LIKE '%%%s%%'", name));
+        }
+
+        if (sort != null && sort.length() > 0) {
+            buf.append(String.format(" ORDER BY %s", sort));
+        }
+
+        buf.append(String.format(" LIMIT %d OFFSET %d", pageSize, start));
+
+
+        List<Resource> result = em.createNativeQuery(buf.toString(), Resource.class).getResultList();
+
+        return result;
+    }
+
+    public Long count(String code, String name) {
+
+        StringBuilder buf = new StringBuilder(String.format("SELECT COUNT(*) FROM %s WHERE 1=1", TABLE));
+
+        if (code != null && code.length() > 0) {
+            buf.append(String.format(" AND code LIKE '%%%s%%'", code));
+        }
+
+        if (name != null && name.length() > 0) {
+            buf.append(String.format(" AND name LIKE '%%%s%%'", name));
+        }
+
+        Query query = em.createNativeQuery(buf.toString());
+        BigInteger totalSize = (BigInteger) query.getSingleResult();
+
+        return totalSize.longValue();
+    }
+}

+ 131 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/service/ResourceService.java

@@ -0,0 +1,131 @@
+package cn.rankin.resourceservice.service;
+
+import cn.rankin.common.utils.entity.api.APICodeManager;
+import cn.rankin.common.utils.entity.api.APIResult;
+import cn.rankin.common.utils.entity.page.Page;
+import cn.rankin.common.utils.entity.dto.ResourceSearchDTO;
+import cn.rankin.resourceservice.dto.ResourceRemote;
+import cn.rankin.resourceservice.entity.Resource;
+import cn.rankin.resourceservice.proxy.RemoteResourceProxy;
+import cn.rankin.resourceservice.repository.ResourceRepository;
+import com.alibaba.fastjson.JSON;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+@Slf4j
+@Service
+public class ResourceService {
+
+    @Autowired
+    private ResourceRepository resourceRepository;
+
+    @Autowired
+    private RemoteResourceProxy resourceProxy;
+
+    @Value("${resource.url.domain}")
+    private String domain;
+
+    public boolean exists(String code) {
+        Long count = resourceRepository.countByCode(code);
+        return count > 0L;
+    }
+
+    public Resource save(Resource resource) {
+        return resourceRepository.save(resource);
+    }
+
+    public APIResult<Page<Resource>> search(String code, String name, String sort, Integer pageNo, Integer pageSize) {
+        Long count = resourceRepository.count(code, name);
+        Page<Resource> page = new Page(count, pageNo, pageSize);
+
+        List<Resource> resourceList = resourceRepository.search(code, name, sort, page.getStart(), pageSize);
+        resourceList.forEach(r -> {
+            initResourceUrl(r);
+        });
+
+        page.setList(resourceList);
+
+        return APIResult.ok(page);
+    }
+
+    public void testAPI() {
+        Long timeBegin = System.currentTimeMillis();
+        resourceProxy.findPageTest(new HashMap<String, Object>() {
+            {
+                this.put("title", "1");
+                this.put("type", 0);
+            }
+        });
+        log.info("not load: {}", System.currentTimeMillis() - timeBegin);
+    }
+
+    public APIResult<Page<Resource>> findRemotePage(ResourceSearchDTO searchDTO) {
+        Long timeBegin = System.currentTimeMillis();
+        APIResult<Page<ResourceRemote>> result = resourceProxy.findPage(new HashMap<String, Object>(){
+            {
+                this.put("title", searchDTO.getName());
+                this.put("pageNum", searchDTO.getPageNo());
+                this.put("pageSize", searchDTO.getPageSize());
+                this.put("type", searchDTO.getType());
+            }
+        });
+        log.info(JSON.toJSONString(System.currentTimeMillis() - timeBegin));
+
+        if (!result.getSuccess()) {
+            log.error("Remote Server Error: code={}, message={}", result.getCode(), result.getMessage());
+            APIResult errResult = APIResult.error(APICodeManager.REMOTE_SERVER_ERROR);
+            result.setMessage(result.getMessage());
+            return errResult;
+        }
+
+        Page<ResourceRemote> remotePage = result.getData();
+        Page<Resource> page = new Page<>(remotePage.getTotalSize(), remotePage.getPageNo(), remotePage.getPageSize());
+
+        List<Resource> resourceList = new ArrayList<>();
+        for (ResourceRemote resourceRemote : remotePage.getList()) {
+            resourceList.addAll(resourceRemote.toNativeResource());
+        }
+
+        page.setList(resourceList);
+
+        return APIResult.ok(page);
+    }
+
+    public APIResult<Page<Resource>> findRemoteByCode(String code) {
+        APIResult<ResourceRemote> result = resourceProxy.findByCode(code);
+        if (!result.getSuccess()) {
+            log.error("Remote Server Error: code={}, message={}", result.getCode(), result.getMessage());
+            APIResult errResult = APIResult.error(APICodeManager.REMOTE_SERVER_ERROR);
+            result.setMessage(result.getMessage());
+            return errResult;
+        }
+
+        List<Resource> resourceList = result.getData().toNativeResource();
+        Page<Resource> page = new Page((long) resourceList.size());
+        page.setList(resourceList);
+
+        return APIResult.ok(page);
+    }
+
+    public void initResourceUrl(Resource resource) {
+        if (resource == null || domain == null) {
+            log.error("domain is null");
+            return;
+        }else if (resource.getPath() == null) {
+            return;
+        }
+
+        String path = resource.getPath();
+        if (path.startsWith("/")) {
+            resource.setUrl(domain + path);
+        }else {
+            resource.setUrl(domain + '/' + path);
+        }
+    }
+}

+ 35 - 0
rankin-resource-service/src/main/java/cn/rankin/resourceservice/vo/OSSSignature.java

@@ -0,0 +1,35 @@
+package cn.rankin.resourceservice.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class OSSSignature implements Serializable{
+
+    private String accessid;
+
+    private String policy;
+
+    private String signature;
+
+    private String expire;
+
+    private String dir;
+
+    private String path;
+
+    private String host;
+
+    public OSSSignature() {}
+
+    public OSSSignature(String accessid) {
+        this.accessid = accessid;
+    }
+
+    public OSSSignature(String accessid, String dir) {
+        this.accessid = accessid;
+        this.dir = dir;
+    }
+
+}

+ 1 - 1
rankin-resource-service/src/main/resources/bootstrap.yml

@@ -5,7 +5,7 @@ spring:
     config:
       uri: http://config.rankin.com:8921
       label: master
-      profile: prod
+      profile: dev
 
 server:
   port: 8200