jidj 6 роки тому
батько
коміт
83c5342b42
21 змінених файлів з 3192 додано та 0 видалено
  1. 5 0
      Dockerfile
  2. 156 0
      pom.xml
  3. 159 0
      src/main/java/com/chinaitop/DatePermissionInterceptor.java
  4. 18 0
      src/main/java/com/chinaitop/DepotPaymentApplication.java
  5. 12 0
      src/main/java/com/chinaitop/HelloWebXml.java
  6. 34 0
      src/main/java/com/chinaitop/SwaggerConfig.java
  7. 151 0
      src/main/java/com/chinaitop/depot/storage/controller/StoragePayMentController.java
  8. 33 0
      src/main/java/com/chinaitop/depot/storage/mapper/StoragePaymentMapper.java
  9. 346 0
      src/main/java/com/chinaitop/depot/storage/mapper/StoragePaymentMapper.xml
  10. 232 0
      src/main/java/com/chinaitop/depot/storage/model/StoragePayment.java
  11. 999 0
      src/main/java/com/chinaitop/depot/storage/model/StoragePaymentExample.java
  12. 25 0
      src/main/java/com/chinaitop/depot/storage/service/StoragePayMentService.java
  13. 45 0
      src/main/java/com/chinaitop/depot/storage/service/impl/StoragePayMentServiceImpl.java
  14. 38 0
      src/main/java/com/chinaitop/depot/storage/utils/CustomFilter.java
  15. 61 0
      src/main/java/com/chinaitop/depot/storage/utils/DataPolicyEngine.java
  16. 170 0
      src/main/java/com/chinaitop/depot/storage/utils/ParameterUtil.java
  17. 61 0
      src/main/java/com/chinaitop/depot/storage/utils/RedisConfig.java
  18. 544 0
      src/main/java/com/chinaitop/depot/storage/utils/RedisUtil.java
  19. 40 0
      src/main/java/com/chinaitop/depot/storage/utils/WebConfig.java
  20. 47 0
      src/main/resources/bootstrap.yml
  21. 16 0
      src/test/java/com/chinaitop/DepotPaymentApplicationTests.java

+ 5 - 0
Dockerfile

@@ -0,0 +1,5 @@
1
+FROM 192.168.123.25:31104/unis/java:8
2
+
3
+ADD ./target/depot-payment.jar /root
4
+CMD ["sh", "-c", "cd /root; java -Djava.security.egd=file:/dev/./urandom -jar /root/depot-payment.jar --depot-payment.server.enable-self-preservation=false"]
5
+EXPOSE 9015

+ 156 - 0
pom.xml

@@ -0,0 +1,156 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+	<modelVersion>4.0.0</modelVersion>
5
+
6
+	<groupId>com.chinaitop</groupId>
7
+	<artifactId>depot-payment</artifactId>
8
+	<version>0.0.1-SNAPSHOT</version>
9
+	<packaging>jar</packaging>
10
+
11
+	<name>depot-payment</name>
12
+	<description>Demo project for Spring Boot</description>
13
+
14
+	<parent>
15
+		<groupId>org.springframework.boot</groupId>
16
+		<artifactId>spring-boot-starter-parent</artifactId>
17
+		<version>2.0.3.RELEASE</version>
18
+		<relativePath/> <!-- lookup parent from repository -->
19
+	</parent>
20
+
21
+	<properties>
22
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
+		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
+		<java.version>1.8</java.version>
25
+		<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
26
+	</properties>
27
+
28
+	<dependencies>
29
+		<dependency>
30
+			<groupId>org.springframework.boot</groupId>
31
+			<artifactId>spring-boot-starter-web</artifactId>
32
+		</dependency>
33
+
34
+		<dependency>
35
+			<groupId>org.mybatis.spring.boot</groupId>
36
+			<artifactId>mybatis-spring-boot-starter</artifactId>
37
+			<version>1.3.1</version>
38
+		</dependency>
39
+		<!-- 引入spring boot自带的pagehelper插件 -->
40
+		<dependency>
41
+			<groupId>com.github.pagehelper</groupId>
42
+			<artifactId>pagehelper-spring-boot-starter</artifactId>
43
+			<version>1.2.3</version>
44
+		</dependency>
45
+		<dependency>
46
+			<groupId>org.springframework.cloud</groupId>
47
+			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
48
+		</dependency>
49
+		<dependency>
50
+            <groupId>org.springframework.cloud</groupId>
51
+            <artifactId>spring-cloud-starter-config</artifactId>
52
+        </dependency>
53
+		<!-- 导入eureka-server服务的依赖 -->
54
+		<!--<dependency>
55
+			<groupId>org.springframework.cloud</groupId>
56
+			<artifactId>spring-cloud-starter-eureka-server</artifactId>
57
+		</dependency>-->
58
+
59
+		<dependency>
60
+			<groupId>org.apache.commons</groupId>
61
+			<artifactId>commons-lang3</artifactId>
62
+			<version>3.7</version>
63
+		</dependency>
64
+
65
+		<!-- swagger2 -->
66
+		<dependency>
67
+			<groupId>io.springfox</groupId>
68
+			<artifactId>springfox-swagger2</artifactId>
69
+			<version>2.6.1</version>
70
+		</dependency>
71
+		<dependency>
72
+			<groupId>io.springfox</groupId>
73
+			<artifactId>springfox-swagger-ui</artifactId>
74
+			<version>2.6.1</version>
75
+		</dependency>
76
+
77
+		<dependency>
78
+			<groupId>org.springframework.boot</groupId>
79
+			<artifactId>spring-boot-starter-data-redis</artifactId>
80
+		</dependency>
81
+		<dependency>
82
+			<groupId>org.springframework.session</groupId>
83
+			<artifactId>spring-session-data-redis</artifactId>
84
+		</dependency>
85
+
86
+		<dependency>
87
+			<groupId>mysql</groupId>
88
+			<artifactId>mysql-connector-java</artifactId>
89
+		</dependency>
90
+		<dependency>
91
+			<groupId>org.springframework.boot</groupId>
92
+			<artifactId>spring-boot-starter-test</artifactId>
93
+			<scope>test</scope>
94
+		</dependency>
95
+        <dependency>
96
+            <groupId>org.mybatis.generator</groupId>
97
+            <artifactId>mybatis-generator-core</artifactId>
98
+            <version>1.3.2</version>
99
+            <scope>compile</scope>
100
+        </dependency>
101
+    </dependencies>
102
+
103
+	<dependencyManagement>
104
+		<dependencies>
105
+			<dependency>
106
+				<groupId>org.springframework.cloud</groupId>
107
+				<artifactId>spring-cloud-dependencies</artifactId>
108
+				<version>${spring-cloud.version}</version>
109
+				<type>pom</type>
110
+				<scope>import</scope>
111
+			</dependency>
112
+		</dependencies>
113
+	</dependencyManagement>
114
+
115
+	<build>
116
+		<finalName>${project.artifactId}</finalName>
117
+		<plugins>
118
+			<plugin>
119
+				<groupId>org.springframework.boot</groupId>
120
+				<artifactId>spring-boot-maven-plugin</artifactId>
121
+			</plugin>
122
+			<plugin>
123
+				<groupId>org.apache.maven.plugins</groupId>
124
+				<artifactId>maven-surefire-plugin</artifactId>
125
+				<configuration>
126
+					<skip>true</skip>
127
+				</configuration>
128
+			</plugin>
129
+		</plugins>
130
+		<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
131
+		<resources>
132
+			<resource>
133
+				<directory>src/main/java</directory>
134
+				<includes>
135
+					<include>**/*.properties</include>
136
+					<include>**/*.xml</include>
137
+				</includes>
138
+				<filtering>false</filtering>
139
+			</resource>
140
+			<resource>
141
+				<directory>src/main/resources</directory>
142
+			</resource>
143
+		</resources>
144
+	</build>
145
+
146
+	<repositories>
147
+		<repository>
148
+			<id>spring-milestones</id>
149
+			<name>Spring Milestones</name>
150
+			<url>https://repo.spring.io/milestone</url>
151
+			<snapshots>
152
+				<enabled>false</enabled>
153
+			</snapshots>
154
+		</repository>
155
+	</repositories>
156
+</project>

+ 159 - 0
src/main/java/com/chinaitop/DatePermissionInterceptor.java

@@ -0,0 +1,159 @@
1
+package com.chinaitop;
2
+
3
+import com.chinaitop.depot.storage.utils.DataPolicyEngine;
4
+import com.chinaitop.depot.storage.utils.RedisUtil;
5
+import net.sf.jsqlparser.parser.CCJSqlParserUtil;
6
+import net.sf.jsqlparser.statement.Statement;
7
+import net.sf.jsqlparser.statement.select.Select;
8
+import net.sf.jsqlparser.util.TablesNamesFinder;
9
+import org.apache.commons.lang.ObjectUtils;
10
+import org.apache.ibatis.executor.statement.StatementHandler;
11
+import org.apache.ibatis.mapping.BoundSql;
12
+import org.apache.ibatis.mapping.MappedStatement;
13
+import org.apache.ibatis.plugin.*;
14
+import org.apache.ibatis.reflection.DefaultReflectorFactory;
15
+import org.apache.ibatis.reflection.MetaObject;
16
+import org.apache.ibatis.reflection.ReflectorFactory;
17
+import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
18
+import org.apache.ibatis.reflection.factory.ObjectFactory;
19
+import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory;
20
+import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
21
+import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.stereotype.Component;
23
+
24
+import java.lang.reflect.Field;
25
+import java.sql.Connection;
26
+import java.util.HashSet;
27
+import java.util.List;
28
+import java.util.Properties;
29
+import java.util.Set;
30
+
31
+/**
32
+ * Sql执行时间记录拦截器
33
+ */
34
+@Intercepts({ @Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class })})
35
+@Component
36
+public class DatePermissionInterceptor implements Interceptor {
37
+	
38
+	private static final ObjectFactory DEFAULT_OBJECT_FACTORY = new DefaultObjectFactory();
39
+    private static final ObjectWrapperFactory DEFAULT_OBJECT_WRAPPER_FACTORY = new DefaultObjectWrapperFactory();
40
+    private static final ReflectorFactory DEFAULT_REFLECTOR_FACTORY = new DefaultReflectorFactory();
41
+
42
+	@Autowired
43
+	private RedisUtil redisUtil;
44
+	
45
+	@Override
46
+	public Object intercept(Invocation invocation) throws Throwable {
47
+		
48
+		StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
49
+        MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, DEFAULT_OBJECT_FACTORY,
50
+                DEFAULT_OBJECT_WRAPPER_FACTORY, DEFAULT_REFLECTOR_FACTORY);
51
+        
52
+        MappedStatement mappedStatement = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement");
53
+        
54
+		final BoundSql boundSql = statementHandler.getBoundSql();
55
+		String bouString = boundSql.getSql();// 获取执行sql 
56
+		
57
+		//sql是查询的才进行权限过滤且不过滤t_url_config表的数据
58
+	    if(mappedStatement.getSqlCommandType().toString().equals("select".toUpperCase()) && 
59
+	    		!bouString.contains("t_url_config")) {
60
+			//通过本地线程获取库id
61
+			Object threadLocalObj = DataPolicyEngine.get();
62
+			String orgId = null;
63
+			if(threadLocalObj != null) {
64
+				orgId = ObjectUtils.toString(threadLocalObj);
65
+			}
66
+			if(orgId!=null) {
67
+				//机构单独查询时使用递归查询,可以查询机构下级机构
68
+				if("com.chinaitop.depot.system.mapper.OrgInfoMapper.selectByExample".equals(mappedStatement.getId())) {
69
+					bouString = bouString.replaceAll("org_info", "(SELECT * from org_info"
70
+							+ " WHERE FIND_IN_SET(org_id,getChildrenOrg("+orgId+"))) org_info ");
71
+				}else {
72
+					//解析sql中的表名
73
+					Statement statement = CCJSqlParserUtil.parse(bouString);
74
+					Select selectStatement = (Select)statement;
75
+					TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
76
+					List<String> result = tablesNamesFinder.getTableList(selectStatement);
77
+					
78
+					Set<String> tableNames = new HashSet<String>();// 定义需要替换的table信息列表
79
+					//获取业务表信息数据
80
+					List<String> tableList = (List<String>)redisUtil.lGetAll("tableList").get(0);
81
+					for(int i=0;i<result.size();i++) {
82
+						for (int j = 0; j < tableList.size(); j++) {// 处理查看sql中是否有业务表
83
+							if (result.get(i).equals(ObjectUtils.toString(tableList.get(j)))) {// 是否存在业务表
84
+								tableNames.add(result.get(i));
85
+							}
86
+						}
87
+					}
88
+					
89
+					if (tableNames != null && tableNames.size() > 0) {// sql中存在业务表进行sql拼接数据重新检索
90
+						if(result.size() >= 2) {//sql中存在2张及以上表
91
+							for (String table : tableNames) {// 进行业务表的数据权限替换
92
+								table += " ";//表名后面加空格,防止两个表名一部分相似,导致替换出错
93
+								bouString = bouString.replaceAll(table, "(SELECT * from " + table
94
+										+ " WHERE org_id = '"+orgId+"') ");
95
+							}
96
+						}else {//sql中是单表
97
+							for (String table : tableNames) {// 进行业务表的数据权限替换
98
+								if(bouString.contains(table+" ")) {//防止是单表查询,表后面没有空格的时候替换不了
99
+									table += " ";//表名后面加空格,防止两个表名一部分相似,导致替换出错
100
+								}
101
+								bouString = bouString.replaceAll(table, "(SELECT * from " + table
102
+										+ " WHERE org_id = '"+orgId+"') "+table+" ");
103
+							}
104
+						}
105
+						
106
+						/*bouString = bouString.replaceAll(table, "(SELECT b.* from " + table
107
+						+ " b,user_business u WHERE b.org_id = u.org_id AND u .user_id ='"+userId+"' AND u.business_type = '"+table+"') ");*/
108
+						
109
+					}
110
+				}
111
+				
112
+				
113
+				//metaStatementHandler.setValue("delegate.boundSql.sql", bouString);
114
+				
115
+				Field field = getField(boundSql, "sql");
116
+				if (field != null) {
117
+					try {
118
+						field.setAccessible(true);
119
+						field.set(boundSql, bouString);
120
+					} catch (IllegalArgumentException e) {
121
+						// TODO Auto-generated catch block
122
+						e.printStackTrace();
123
+					} catch (IllegalAccessException e) {
124
+						// TODO Auto-generated catch block
125
+						e.printStackTrace();
126
+					}
127
+				}
128
+			}
129
+		
130
+	    }
131
+			
132
+		return invocation.proceed();
133
+		
134
+
135
+	}
136
+
137
+	private static Field getField(Object obj, String fieldName) {
138
+		Field field = null;
139
+		for (Class<?> clazz = obj.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
140
+			try {
141
+				field = clazz.getDeclaredField(fieldName);
142
+				break;
143
+			} catch (NoSuchFieldException e) {
144
+				// 这里不用做处理,子类没有该字段可能对应的父类有,都没有就返回null。
145
+			}
146
+		}
147
+		return field;
148
+	}
149
+
150
+	@Override
151
+	public Object plugin(Object target) {
152
+		return Plugin.wrap(target, this);
153
+	}
154
+
155
+	@Override
156
+	public void setProperties(Properties properties) {
157
+	}
158
+
159
+}

+ 18 - 0
src/main/java/com/chinaitop/DepotPaymentApplication.java

@@ -0,0 +1,18 @@
1
+package com.chinaitop;
2
+
3
+import org.mybatis.spring.annotation.MapperScan;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
8
+
9
+@EnableEurekaClient
10
+@EnableDiscoveryClient
11
+@SpringBootApplication
12
+@MapperScan(basePackages = {"com.chinaitop.depot.*.mapper"})
13
+public class DepotPaymentApplication {
14
+
15
+	public static void main(String[] args) {
16
+		SpringApplication.run(DepotPaymentApplication.class, args);
17
+	}
18
+}

+ 12 - 0
src/main/java/com/chinaitop/HelloWebXml.java

@@ -0,0 +1,12 @@
1
+package com.chinaitop;
2
+ 
3
+import org.springframework.boot.builder.SpringApplicationBuilder;
4
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
5
+
6
+public class HelloWebXml extends SpringBootServletInitializer {
7
+    @Override
8
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
9
+        return application.sources(DepotPaymentApplication.class);
10
+    }
11
+ 
12
+}

+ 34 - 0
src/main/java/com/chinaitop/SwaggerConfig.java

@@ -0,0 +1,34 @@
1
+package com.chinaitop;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import springfox.documentation.builders.ApiInfoBuilder;
6
+import springfox.documentation.builders.PathSelectors;
7
+import springfox.documentation.builders.RequestHandlerSelectors;
8
+import springfox.documentation.service.ApiInfo;
9
+import springfox.documentation.spi.DocumentationType;
10
+import springfox.documentation.spring.web.plugins.Docket;
11
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
12
+
13
+@Configuration
14
+@EnableSwagger2
15
+public class SwaggerConfig {
16
+
17
+    @Bean
18
+    public Docket createRestApi() {
19
+        return new Docket(DocumentationType.SWAGGER_2)
20
+                .apiInfo(apiInfo())
21
+                .select()
22
+                .apis(RequestHandlerSelectors.basePackage("com.chinaitop.depot.storage.controller"))
23
+                .paths(PathSelectors.any())
24
+                .build();
25
+    }
26
+    private ApiInfo apiInfo() {
27
+        return new ApiInfoBuilder()
28
+                .title("智能粮库管理平台api文档")
29
+                .description("费用管理")
30
+                .termsOfServiceUrl("http://192.168.80.25:9001")
31
+                .version("1.0")
32
+                .build();
33
+    }
34
+}

+ 151 - 0
src/main/java/com/chinaitop/depot/storage/controller/StoragePayMentController.java

@@ -0,0 +1,151 @@
1
+package com.chinaitop.depot.storage.controller;
2
+
3
+import com.chinaitop.depot.storage.model.StoragePayment;
4
+import com.chinaitop.depot.storage.model.StoragePaymentExample;
5
+import com.chinaitop.depot.storage.service.StoragePayMentService;
6
+import com.chinaitop.depot.storage.utils.ParameterUtil;
7
+import com.fasterxml.jackson.databind.ObjectMapper;
8
+import com.github.pagehelper.PageHelper;
9
+import com.github.pagehelper.PageInfo;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiImplicitParam;
12
+import io.swagger.annotations.ApiImplicitParams;
13
+import io.swagger.annotations.ApiOperation;
14
+import org.springframework.http.MediaType;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RestController;
18
+
19
+import javax.annotation.Resource;
20
+import java.io.IOException;
21
+import java.util.Date;
22
+import java.util.HashMap;
23
+import java.util.List;
24
+import java.util.Map;
25
+
26
+/**
27
+ * @auther mafy
28
+ * @createtime 2017/10/25 0025
29
+ * 费用管理类
30
+ */
31
+@RestController
32
+@RequestMapping(value = "/storagePayMent")
33
+@Api(value= "StoragePayMentController", description = "费用管理控制类")
34
+public class StoragePayMentController {
35
+
36
+    @Resource
37
+    private StoragePayMentService storagePayMentService;
38
+    /**
39
+     * 获取费用管理列表
40
+     * @param pageNum
41
+     * @param pageSize
42
+     * @param houseId
43
+     * @param searchStartDate
44
+     * @param searchEndDate
45
+     * @return
46
+     */
47
+    @RequestMapping(value = "/getpaymentList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
48
+    @ApiOperation(value="查询费用管理列表", notes = "查询费用管理信息列表,支持分页")
49
+    @ApiImplicitParams({
50
+            @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
51
+            @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
52
+            @ApiImplicitParam(name = "houseId", value = "仓房id", paramType = "query"),
53
+            @ApiImplicitParam(name = "type", value = "费用类型", paramType = "query"),
54
+            @ApiImplicitParam(name = "searchStartDate", value = "开始日期", paramType = "query"),
55
+            @ApiImplicitParam(name = "searchEndDate", value = "结束日期", paramType = "query")
56
+
57
+    })
58
+    public PageInfo<StoragePayment> getpaymentList(Integer pageNum, Integer pageSize, Integer houseId, Integer type, String searchStartDate, String searchEndDate){
59
+        StoragePaymentExample storagePaymentExample = new StoragePaymentExample();
60
+        StoragePaymentExample.Criteria criteria = storagePaymentExample.createCriteria();
61
+        if(ParameterUtil.isnotnull(houseId)){
62
+           criteria.andHouseIdEqualTo(houseId);
63
+        }
64
+        if(ParameterUtil.isnotnull(type)){
65
+            criteria.andTypeEqualTo(type);
66
+        }
67
+
68
+        if(ParameterUtil.isnotnull(searchStartDate) && ParameterUtil.isnotnull(searchEndDate)){
69
+            Date starDate = ParameterUtil.string2datetime(searchStartDate + " 00:00:00");
70
+            criteria.andPayTimeGreaterThanOrEqualTo(starDate);
71
+
72
+            Date endDate = ParameterUtil.string2datetime(searchEndDate + " 23:59:59");
73
+            criteria.andPayTimeLessThanOrEqualTo(endDate);
74
+        }
75
+
76
+        if (pageNum!=null && pageSize!=null) {
77
+            PageHelper.startPage(pageNum, pageSize);
78
+        }
79
+
80
+        List<StoragePayment> list = storagePayMentService.getlist(storagePaymentExample);
81
+        PageInfo<StoragePayment> pageInfo = new PageInfo<StoragePayment>(list);
82
+        return pageInfo;
83
+    }
84
+    /**
85
+     * 获取费用ById
86
+     * @return
87
+     */
88
+    @RequestMapping(value = "/getpaymentListById" ,produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
89
+    @ApiOperation(value="获取费用ById", notes = "获取费用ById")
90
+    @ApiImplicitParams({
91
+            @ApiImplicitParam(name = "id", value = "id", paramType = "query"),
92
+    })
93
+    public StoragePayment getpaymentListById(Integer id){
94
+        return storagePayMentService.getObjById(id);
95
+    }
96
+
97
+    /**
98
+     * 新增
99
+     * @param paymentJson
100
+     * @return
101
+     */
102
+    @RequestMapping(value = "edit" ,produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
103
+    @ApiOperation(value="新增数据", notes = "新增数据")
104
+    @ApiImplicitParams({
105
+            @ApiImplicitParam(name = "paymentJson", value = "JSON数据对象", paramType = "form"),
106
+            @ApiImplicitParam(name = "orgId", value = "登陆人id", paramType = "orgId"),
107
+    })
108
+    public Map<String,String> edit(String paymentJson,Integer orgId){
109
+        ObjectMapper mapper = new ObjectMapper();
110
+        try {
111
+            StoragePayment storagePayment = (StoragePayment) mapper.readValue(paymentJson, StoragePayment.class);
112
+            storagePayment.setOrgId(orgId);
113
+            if(ParameterUtil.isnotnull(storagePayment.getId())){
114
+                storagePayMentService.update(storagePayment);
115
+            }else{
116
+                storagePayMentService.insert(storagePayment);
117
+            }
118
+        } catch (IOException e) {
119
+            e.printStackTrace();
120
+        }
121
+        return null;
122
+    }
123
+
124
+    /**
125
+     * 移除
126
+     * @param id
127
+     * @return
128
+     */
129
+    @RequestMapping(value = "remove", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
130
+    @ApiOperation(value="按ID删除费用信息", notes = "按ID删除费用信息")
131
+    @ApiImplicitParams({
132
+            @ApiImplicitParam(name = "id", value = "数据ID", paramType = "form")
133
+    })
134
+    public Map<String,String> remove(Integer id){
135
+        Map<String,String> map = new HashMap<String, String>();
136
+         storagePayMentService.remove(id);
137
+        map.put("status","success");
138
+        return map;
139
+    }
140
+}
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+

+ 33 - 0
src/main/java/com/chinaitop/depot/storage/mapper/StoragePaymentMapper.java

@@ -0,0 +1,33 @@
1
+package com.chinaitop.depot.storage.mapper;
2
+
3
+import com.chinaitop.depot.storage.model.StoragePayment;
4
+import com.chinaitop.depot.storage.model.StoragePaymentExample;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+
9
+public interface StoragePaymentMapper {
10
+    int countByExample(StoragePaymentExample example);
11
+
12
+    int deleteByExample(StoragePaymentExample example);
13
+
14
+    int deleteByPrimaryKey(Integer id);
15
+
16
+    int insert(StoragePayment record);
17
+
18
+    int insertSelective(StoragePayment record);
19
+
20
+    List<StoragePayment> selectByExample(StoragePaymentExample example);
21
+
22
+    StoragePayment selectByPrimaryKey(Integer id);
23
+
24
+    int updateByExampleSelective(@Param("record") StoragePayment record, @Param("example") StoragePaymentExample example);
25
+
26
+    int updateByExample(@Param("record") StoragePayment record, @Param("example") StoragePaymentExample example);
27
+
28
+    int updateByPrimaryKeySelective(StoragePayment record);
29
+
30
+    int updateByPrimaryKey(StoragePayment record);
31
+
32
+    List<StoragePayment> queryByExample(StoragePaymentExample example);
33
+}

+ 346 - 0
src/main/java/com/chinaitop/depot/storage/mapper/StoragePaymentMapper.xml

@@ -0,0 +1,346 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.chinaitop.depot.storage.mapper.StoragePaymentMapper">
4
+  <resultMap id="BaseResultMap" type="com.chinaitop.depot.storage.model.StoragePayment">
5
+    <id column="id" jdbcType="INTEGER" property="id" />
6
+    <result column="org_id" jdbcType="INTEGER" property="orgId" />
7
+    <result column="unit" jdbcType="VARCHAR" property="unit" />
8
+    <result column="house_id" jdbcType="INTEGER" property="houseId" />
9
+    <result column="recorder" jdbcType="VARCHAR" property="recorder" />
10
+    <result column="count" jdbcType="VARCHAR" property="count" />
11
+    <result column="type" jdbcType="INTEGER" property="type" />
12
+    <result column="sub_type" jdbcType="INTEGER" property="subType" />
13
+    <result column="pay_time" jdbcType="TIMESTAMP" property="payTime" />
14
+    <result column="price" jdbcType="VARCHAR" property="price" />
15
+    <result column="number" jdbcType="VARCHAR" property="number" />
16
+    <result column="pay_content" jdbcType="VARCHAR" property="payContent" />
17
+  </resultMap>
18
+  <sql id="Example_Where_Clause">
19
+    <where>
20
+      <foreach collection="oredCriteria" item="criteria" separator="or">
21
+        <if test="criteria.valid">
22
+          <trim prefix="(" prefixOverrides="and" suffix=")">
23
+            <foreach collection="criteria.criteria" item="criterion">
24
+              <choose>
25
+                <when test="criterion.noValue">
26
+                  and ${criterion.condition}
27
+                </when>
28
+                <when test="criterion.singleValue">
29
+                  and ${criterion.condition} #{criterion.value}
30
+                </when>
31
+                <when test="criterion.betweenValue">
32
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
33
+                </when>
34
+                <when test="criterion.listValue">
35
+                  and ${criterion.condition}
36
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
37
+                    #{listItem}
38
+                  </foreach>
39
+                </when>
40
+              </choose>
41
+            </foreach>
42
+          </trim>
43
+        </if>
44
+      </foreach>
45
+    </where>
46
+  </sql>
47
+  <sql id="Update_By_Example_Where_Clause">
48
+    <where>
49
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
50
+        <if test="criteria.valid">
51
+          <trim prefix="(" prefixOverrides="and" suffix=")">
52
+            <foreach collection="criteria.criteria" item="criterion">
53
+              <choose>
54
+                <when test="criterion.noValue">
55
+                  and ${criterion.condition}
56
+                </when>
57
+                <when test="criterion.singleValue">
58
+                  and ${criterion.condition} #{criterion.value}
59
+                </when>
60
+                <when test="criterion.betweenValue">
61
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
62
+                </when>
63
+                <when test="criterion.listValue">
64
+                  and ${criterion.condition}
65
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
66
+                    #{listItem}
67
+                  </foreach>
68
+                </when>
69
+              </choose>
70
+            </foreach>
71
+          </trim>
72
+        </if>
73
+      </foreach>
74
+    </where>
75
+  </sql>
76
+  <sql id="Base_Column_List">
77
+    id, org_id, unit, house_id, recorder, count, type, sub_type, pay_time, price, number, 
78
+    pay_content
79
+  </sql>
80
+  <select id="selectByExample" parameterType="com.chinaitop.depot.storage.model.StoragePaymentExample" resultMap="BaseResultMap">
81
+    select
82
+    <if test="distinct">
83
+      distinct
84
+    </if>
85
+    <include refid="Base_Column_List" />
86
+    from storage_payment
87
+    <if test="_parameter != null">
88
+      <include refid="Example_Where_Clause" />
89
+    </if>
90
+    <if test="orderByClause != null">
91
+      order by ${orderByClause}
92
+    </if>
93
+  </select>
94
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
95
+    select 
96
+    <include refid="Base_Column_List" />
97
+    from storage_payment
98
+    where id = #{id,jdbcType=INTEGER}
99
+  </select>
100
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
101
+    delete from storage_payment
102
+    where id = #{id,jdbcType=INTEGER}
103
+  </delete>
104
+  <delete id="deleteByExample" parameterType="com.chinaitop.depot.storage.model.StoragePaymentExample">
105
+    delete from storage_payment
106
+    <if test="_parameter != null">
107
+      <include refid="Example_Where_Clause" />
108
+    </if>
109
+  </delete>
110
+  <insert id="insert" parameterType="com.chinaitop.depot.storage.model.StoragePayment">
111
+    insert into storage_payment (id, org_id, unit, 
112
+      house_id, recorder, count, 
113
+      type, sub_type, pay_time, 
114
+      price, number, pay_content
115
+      )
116
+    values (#{id,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, #{unit,jdbcType=VARCHAR}, 
117
+      #{houseId,jdbcType=INTEGER}, #{recorder,jdbcType=VARCHAR}, #{count,jdbcType=VARCHAR}, 
118
+      #{type,jdbcType=INTEGER}, #{subType,jdbcType=INTEGER}, #{payTime,jdbcType=TIMESTAMP}, 
119
+      #{price,jdbcType=VARCHAR}, #{number,jdbcType=VARCHAR}, #{payContent,jdbcType=VARCHAR}
120
+      )
121
+  </insert>
122
+  <insert id="insertSelective" parameterType="com.chinaitop.depot.storage.model.StoragePayment">
123
+    insert into storage_payment
124
+    <trim prefix="(" suffix=")" suffixOverrides=",">
125
+      <if test="id != null">
126
+        id,
127
+      </if>
128
+      <if test="orgId != null">
129
+        org_id,
130
+      </if>
131
+      <if test="unit != null">
132
+        unit,
133
+      </if>
134
+      <if test="houseId != null">
135
+        house_id,
136
+      </if>
137
+      <if test="recorder != null">
138
+        recorder,
139
+      </if>
140
+      <if test="count != null">
141
+        count,
142
+      </if>
143
+      <if test="type != null">
144
+        type,
145
+      </if>
146
+      <if test="subType != null">
147
+        sub_type,
148
+      </if>
149
+      <if test="payTime != null">
150
+        pay_time,
151
+      </if>
152
+      <if test="price != null">
153
+        price,
154
+      </if>
155
+      <if test="number != null">
156
+        number,
157
+      </if>
158
+      <if test="payContent != null">
159
+        pay_content,
160
+      </if>
161
+    </trim>
162
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
163
+      <if test="id != null">
164
+        #{id,jdbcType=INTEGER},
165
+      </if>
166
+      <if test="orgId != null">
167
+        #{orgId,jdbcType=INTEGER},
168
+      </if>
169
+      <if test="unit != null">
170
+        #{unit,jdbcType=VARCHAR},
171
+      </if>
172
+      <if test="houseId != null">
173
+        #{houseId,jdbcType=INTEGER},
174
+      </if>
175
+      <if test="recorder != null">
176
+        #{recorder,jdbcType=VARCHAR},
177
+      </if>
178
+      <if test="count != null">
179
+        #{count,jdbcType=VARCHAR},
180
+      </if>
181
+      <if test="type != null">
182
+        #{type,jdbcType=INTEGER},
183
+      </if>
184
+      <if test="subType != null">
185
+        #{subType,jdbcType=INTEGER},
186
+      </if>
187
+      <if test="payTime != null">
188
+        #{payTime,jdbcType=TIMESTAMP},
189
+      </if>
190
+      <if test="price != null">
191
+        #{price,jdbcType=VARCHAR},
192
+      </if>
193
+      <if test="number != null">
194
+        #{number,jdbcType=VARCHAR},
195
+      </if>
196
+      <if test="payContent != null">
197
+        #{payContent,jdbcType=VARCHAR},
198
+      </if>
199
+    </trim>
200
+  </insert>
201
+  <select id="countByExample" parameterType="com.chinaitop.depot.storage.model.StoragePaymentExample" resultType="java.lang.Integer">
202
+    select count(*) from storage_payment
203
+    <if test="_parameter != null">
204
+      <include refid="Example_Where_Clause" />
205
+    </if>
206
+  </select>
207
+  <update id="updateByExampleSelective" parameterType="map">
208
+    update storage_payment
209
+    <set>
210
+      <if test="record.id != null">
211
+        id = #{record.id,jdbcType=INTEGER},
212
+      </if>
213
+      <if test="record.orgId != null">
214
+        org_id = #{record.orgId,jdbcType=INTEGER},
215
+      </if>
216
+      <if test="record.unit != null">
217
+        unit = #{record.unit,jdbcType=VARCHAR},
218
+      </if>
219
+      <if test="record.houseId != null">
220
+        house_id = #{record.houseId,jdbcType=INTEGER},
221
+      </if>
222
+      <if test="record.recorder != null">
223
+        recorder = #{record.recorder,jdbcType=VARCHAR},
224
+      </if>
225
+      <if test="record.count != null">
226
+        count = #{record.count,jdbcType=VARCHAR},
227
+      </if>
228
+      <if test="record.type != null">
229
+        type = #{record.type,jdbcType=INTEGER},
230
+      </if>
231
+      <if test="record.subType != null">
232
+        sub_type = #{record.subType,jdbcType=INTEGER},
233
+      </if>
234
+      <if test="record.payTime != null">
235
+        pay_time = #{record.payTime,jdbcType=TIMESTAMP},
236
+      </if>
237
+      <if test="record.price != null">
238
+        price = #{record.price,jdbcType=VARCHAR},
239
+      </if>
240
+      <if test="record.number != null">
241
+        number = #{record.number,jdbcType=VARCHAR},
242
+      </if>
243
+      <if test="record.payContent != null">
244
+        pay_content = #{record.payContent,jdbcType=VARCHAR},
245
+      </if>
246
+    </set>
247
+    <if test="_parameter != null">
248
+      <include refid="Update_By_Example_Where_Clause" />
249
+    </if>
250
+  </update>
251
+  <update id="updateByExample" parameterType="map">
252
+    update storage_payment
253
+    set id = #{record.id,jdbcType=INTEGER},
254
+      org_id = #{record.orgId,jdbcType=INTEGER},
255
+      unit = #{record.unit,jdbcType=VARCHAR},
256
+      house_id = #{record.houseId,jdbcType=INTEGER},
257
+      recorder = #{record.recorder,jdbcType=VARCHAR},
258
+      count = #{record.count,jdbcType=VARCHAR},
259
+      type = #{record.type,jdbcType=INTEGER},
260
+      sub_type = #{record.subType,jdbcType=INTEGER},
261
+      pay_time = #{record.payTime,jdbcType=TIMESTAMP},
262
+      price = #{record.price,jdbcType=VARCHAR},
263
+      number = #{record.number,jdbcType=VARCHAR},
264
+      pay_content = #{record.payContent,jdbcType=VARCHAR}
265
+    <if test="_parameter != null">
266
+      <include refid="Update_By_Example_Where_Clause" />
267
+    </if>
268
+  </update>
269
+  <update id="updateByPrimaryKeySelective" parameterType="com.chinaitop.depot.storage.model.StoragePayment">
270
+    update storage_payment
271
+    <set>
272
+      <if test="orgId != null">
273
+        org_id = #{orgId,jdbcType=INTEGER},
274
+      </if>
275
+      <if test="unit != null">
276
+        unit = #{unit,jdbcType=VARCHAR},
277
+      </if>
278
+      <if test="houseId != null">
279
+        house_id = #{houseId,jdbcType=INTEGER},
280
+      </if>
281
+      <if test="recorder != null">
282
+        recorder = #{recorder,jdbcType=VARCHAR},
283
+      </if>
284
+      <if test="count != null">
285
+        count = #{count,jdbcType=VARCHAR},
286
+      </if>
287
+      <if test="type != null">
288
+        type = #{type,jdbcType=INTEGER},
289
+      </if>
290
+      <if test="subType != null">
291
+        sub_type = #{subType,jdbcType=INTEGER},
292
+      </if>
293
+      <if test="payTime != null">
294
+        pay_time = #{payTime,jdbcType=TIMESTAMP},
295
+      </if>
296
+      <if test="price != null">
297
+        price = #{price,jdbcType=VARCHAR},
298
+      </if>
299
+      <if test="number != null">
300
+        number = #{number,jdbcType=VARCHAR},
301
+      </if>
302
+      <if test="payContent != null">
303
+        pay_content = #{payContent,jdbcType=VARCHAR},
304
+      </if>
305
+    </set>
306
+    where id = #{id,jdbcType=INTEGER}
307
+  </update>
308
+  <update id="updateByPrimaryKey" parameterType="com.chinaitop.depot.storage.model.StoragePayment">
309
+    update storage_payment
310
+    set org_id = #{orgId,jdbcType=INTEGER},
311
+      unit = #{unit,jdbcType=VARCHAR},
312
+      house_id = #{houseId,jdbcType=INTEGER},
313
+      recorder = #{recorder,jdbcType=VARCHAR},
314
+      count = #{count,jdbcType=VARCHAR},
315
+      type = #{type,jdbcType=INTEGER},
316
+      sub_type = #{subType,jdbcType=INTEGER},
317
+      pay_time = #{payTime,jdbcType=TIMESTAMP},
318
+      price = #{price,jdbcType=VARCHAR},
319
+      number = #{number,jdbcType=VARCHAR},
320
+      pay_content = #{payContent,jdbcType=VARCHAR}
321
+    where id = #{id,jdbcType=INTEGER}
322
+  </update>
323
+
324
+  <sql id="ExtBase_Column_List">
325
+    spt.id, spt.org_id, spt.unit, spt.house_id, spt.recorder, spt.count, spt.type, spt.sub_type, spt.pay_time, spt.price, spt.number,
326
+    spt.pay_content
327
+  </sql>
328
+
329
+  <select id="queryByExample" parameterType="com.chinaitop.depot.storage.model.StoragePaymentExample" resultMap="BaseResultMap">
330
+    select
331
+    <if test="distinct">
332
+      distinct
333
+    </if>
334
+    <include refid="ExtBase_Column_List" />,
335
+    bs.storeHouse_name storehouseName
336
+    FROM storage_payment spt
337
+    LEFT JOIN basic_storehouse bs on bs.storehouse_id = spt.house_id
338
+    <if test="_parameter != null">
339
+      <include refid="Example_Where_Clause" />
340
+    </if>
341
+   <!--<if test="orderByClause != null">
342
+      order by ${orderByClause}
343
+    </if>-->
344
+    order by spt.pay_time DESC
345
+  </select>
346
+</mapper>

+ 232 - 0
src/main/java/com/chinaitop/depot/storage/model/StoragePayment.java

@@ -0,0 +1,232 @@
1
+package com.chinaitop.depot.storage.model;
2
+
3
+import java.util.Date;
4
+
5
+public class StoragePayment {
6
+    private Integer id;
7
+
8
+    private Integer orgId;
9
+
10
+    private String unit;
11
+
12
+    private Integer houseId;
13
+
14
+    private String recorder;
15
+
16
+    private String count;
17
+
18
+    private Integer type;
19
+
20
+    private Integer subType;
21
+
22
+    private Date payTime;
23
+
24
+    private String price;
25
+
26
+    private String number;
27
+
28
+    private String payContent;
29
+
30
+    //业务字段
31
+    private String storehouseName;//仓房编号
32
+
33
+    /**
34
+     * ID
35
+     * @return id ID
36
+     */
37
+    public Integer getId() {
38
+        return id;
39
+    }
40
+
41
+    /**
42
+     * ID
43
+     * @param id ID
44
+     */
45
+    public void setId(Integer id) {
46
+        this.id = id;
47
+    }
48
+
49
+    /**
50
+     * 库级id
51
+     * @return org_id 库级id
52
+     */
53
+    public Integer getOrgId() {
54
+        return orgId;
55
+    }
56
+
57
+    /**
58
+     * 库级id
59
+     * @param orgId 库级id
60
+     */
61
+    public void setOrgId(Integer orgId) {
62
+        this.orgId = orgId;
63
+    }
64
+
65
+    /**
66
+     * 单位
67
+     * @return unit 单位
68
+     */
69
+    public String getUnit() {
70
+        return unit;
71
+    }
72
+
73
+    /**
74
+     * 单位
75
+     * @param unit 单位
76
+     */
77
+    public void setUnit(String unit) {
78
+        this.unit = unit == null ? null : unit.trim();
79
+    }
80
+
81
+    /**
82
+     * 仓房ID
83
+     * @return house_id 仓房ID
84
+     */
85
+    public Integer getHouseId() {
86
+        return houseId;
87
+    }
88
+
89
+    /**
90
+     * 仓房ID
91
+     * @param houseId 仓房ID
92
+     */
93
+    public void setHouseId(Integer houseId) {
94
+        this.houseId = houseId;
95
+    }
96
+
97
+    /**
98
+     * 负责人
99
+     * @return recorder 负责人
100
+     */
101
+    public String getRecorder() {
102
+        return recorder;
103
+    }
104
+
105
+    /**
106
+     * 负责人
107
+     * @param recorder 负责人
108
+     */
109
+    public void setRecorder(String recorder) {
110
+        this.recorder = recorder == null ? null : recorder.trim();
111
+    }
112
+
113
+    /**
114
+     * 产生费用
115
+     * @return count 产生费用
116
+     */
117
+    public String getCount() {
118
+        return count;
119
+    }
120
+
121
+    /**
122
+     * 产生费用
123
+     * @param count 产生费用
124
+     */
125
+    public void setCount(String count) {
126
+        this.count = count == null ? null : count.trim();
127
+    }
128
+
129
+    /**
130
+     * 产生费用类型
131
+     * @return type 产生费用类型
132
+     */
133
+    public Integer getType() {
134
+        return type;
135
+    }
136
+
137
+    /**
138
+     * 产生费用类型
139
+     * @param type 产生费用类型
140
+     */
141
+    public void setType(Integer type) {
142
+        this.type = type;
143
+    }
144
+
145
+    /**
146
+     * 产生费用子类型
147
+     * @return sub_type 产生费用子类型
148
+     */
149
+    public Integer getSubType() {
150
+        return subType;
151
+    }
152
+
153
+    /**
154
+     * 产生费用子类型
155
+     * @param subType 产生费用子类型
156
+     */
157
+    public void setSubType(Integer subType) {
158
+        this.subType = subType;
159
+    }
160
+
161
+    /**
162
+     * 产生费用时间
163
+     * @return pay_time 产生费用时间
164
+     */
165
+    public Date getPayTime() {
166
+        return payTime;
167
+    }
168
+
169
+    /**
170
+     * 产生费用时间
171
+     * @param payTime 产生费用时间
172
+     */
173
+    public void setPayTime(Date payTime) {
174
+        this.payTime = payTime;
175
+    }
176
+
177
+    /**
178
+     * 单价
179
+     * @return price 单价
180
+     */
181
+    public String getPrice() {
182
+        return price;
183
+    }
184
+
185
+    /**
186
+     * 单价
187
+     * @param price 单价
188
+     */
189
+    public void setPrice(String price) {
190
+        this.price = price == null ? null : price.trim();
191
+    }
192
+
193
+    /**
194
+     * 数量
195
+     * @return number 数量
196
+     */
197
+    public String getNumber() {
198
+        return number;
199
+    }
200
+
201
+    /**
202
+     * 数量
203
+     * @param number 数量
204
+     */
205
+    public void setNumber(String number) {
206
+        this.number = number == null ? null : number.trim();
207
+    }
208
+
209
+    /**
210
+     * 费用产生的原因
211
+     * @return pay_content 费用产生的原因
212
+     */
213
+    public String getPayContent() {
214
+        return payContent;
215
+    }
216
+
217
+    /**
218
+     * 费用产生的原因
219
+     * @param payContent 费用产生的原因
220
+     */
221
+    public void setPayContent(String payContent) {
222
+        this.payContent = payContent == null ? null : payContent.trim();
223
+    }
224
+
225
+    public String getStorehouseName() {
226
+        return storehouseName;
227
+    }
228
+
229
+    public void setStorehouseName(String storehouseName) {
230
+        this.storehouseName = storehouseName;
231
+    }
232
+}

Різницю між файлами не показано, бо вона завелика
+ 999 - 0
src/main/java/com/chinaitop/depot/storage/model/StoragePaymentExample.java


+ 25 - 0
src/main/java/com/chinaitop/depot/storage/service/StoragePayMentService.java

@@ -0,0 +1,25 @@
1
+package com.chinaitop.depot.storage.service;
2
+
3
+import com.chinaitop.depot.storage.model.StoragePayment;
4
+import com.chinaitop.depot.storage.model.StoragePaymentExample;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * @auther mafy
10
+ * @createtime 2017/10/25 0025
11
+ */
12
+public interface StoragePayMentService {
13
+
14
+    List<StoragePayment> getlist(StoragePaymentExample storagePaymentExample);
15
+
16
+    StoragePayment getObjById(Integer id);
17
+
18
+    void insert(StoragePayment storagePayment);
19
+
20
+    void update(StoragePayment storagePayment);
21
+
22
+    void remove(Integer id);
23
+
24
+
25
+}

+ 45 - 0
src/main/java/com/chinaitop/depot/storage/service/impl/StoragePayMentServiceImpl.java

@@ -0,0 +1,45 @@
1
+package com.chinaitop.depot.storage.service.impl;
2
+
3
+import com.chinaitop.depot.storage.mapper.StoragePaymentMapper;
4
+import com.chinaitop.depot.storage.model.StoragePayment;
5
+import com.chinaitop.depot.storage.model.StoragePaymentExample;
6
+import com.chinaitop.depot.storage.service.StoragePayMentService;
7
+import org.springframework.stereotype.Service;
8
+
9
+import javax.annotation.Resource;
10
+import java.util.List;
11
+
12
+/**
13
+ * @auther mafy
14
+ * @createtime 2017/10/25 0025
15
+ */
16
+@Service
17
+public class StoragePayMentServiceImpl implements StoragePayMentService {
18
+
19
+    @Resource
20
+    private StoragePaymentMapper storagePaymentMapper;
21
+    @Override
22
+    public List<StoragePayment> getlist(StoragePaymentExample storagePaymentExample) {
23
+        return storagePaymentMapper.queryByExample(storagePaymentExample);
24
+    }
25
+
26
+    @Override
27
+    public void insert(StoragePayment storagePayment) {
28
+        storagePaymentMapper.insertSelective(storagePayment);
29
+    }
30
+
31
+    @Override
32
+    public void update(StoragePayment storagePayment) {
33
+        storagePaymentMapper.updateByPrimaryKeySelective(storagePayment);
34
+    }
35
+
36
+    @Override
37
+    public void remove(Integer id) {
38
+        storagePaymentMapper.deleteByPrimaryKey(id);
39
+    }
40
+
41
+    @Override
42
+    public StoragePayment getObjById(Integer id) {
43
+        return storagePaymentMapper.selectByPrimaryKey(id);
44
+    }
45
+}

+ 38 - 0
src/main/java/com/chinaitop/depot/storage/utils/CustomFilter.java

@@ -0,0 +1,38 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import org.apache.commons.lang.ObjectUtils;
4
+
5
+import javax.servlet.*;
6
+import javax.servlet.http.HttpServletRequest;
7
+import javax.servlet.http.HttpSession;
8
+import java.io.IOException;
9
+
10
+public class CustomFilter implements Filter {
11
+
12
+	@Override
13
+    public void init(FilterConfig filterConfig) throws ServletException {
14
+ 
15
+    }
16
+	
17
+	@Override
18
+	public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
19
+			throws IOException, ServletException {
20
+		HttpServletRequest request = (HttpServletRequest) arg0;
21
+		HttpSession session = request.getSession();
22
+		String orgId = "";
23
+		if (session != null){
24
+			orgId = ObjectUtils.toString(session.getAttribute("orgId"),"");
25
+		}
26
+		if (!orgId.isEmpty()) {
27
+			DataPolicyEngine.set(orgId);
28
+		}
29
+		arg2.doFilter(arg0, arg1);
30
+		DataPolicyEngine.remove();
31
+	}
32
+	
33
+	@Override
34
+    public void destroy() {
35
+ 
36
+    }
37
+
38
+}

+ 61 - 0
src/main/java/com/chinaitop/depot/storage/utils/DataPolicyEngine.java

@@ -0,0 +1,61 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
5
+
6
+
7
+/**
8
+ * 
9
+ * @author hf
10
+ * 
11
+ * @description 数据策略(数据权限控制使用)
12
+ * 
13
+ * 
14
+ */
15
+public class DataPolicyEngine {
16
+	//log信息输出对象
17
+	protected static final Log log = LogFactory.getLog(DataPolicyEngine.class); 
18
+
19
+	//本地线程,用于存储线程公共对象
20
+	private static ThreadLocal threadLocalSession = new ThreadLocal();
21
+	
22
+	
23
+	/**
24
+	 * @description 获取本地执行线程
25
+	 *
26
+	 * @return ThreadLocal 
27
+	 * 
28
+	 */
29
+	public static ThreadLocal getThreadLocalSession() {
30
+		return threadLocalSession;
31
+	}
32
+	
33
+	/**
34
+	 * @description 在线程内设置存储对象
35
+	 * 
36
+	 */
37
+	public static void set(Object obj) {
38
+		threadLocalSession.set(obj);
39
+
40
+	}
41
+	
42
+	/**
43
+	 * @description 获取在线程内设置存储的对象
44
+	 * 
45
+	 */
46
+	public static Object get() {
47
+		return threadLocalSession.get();
48
+
49
+	}
50
+
51
+	/**
52
+	 * @description 移除在线程内设置存储的对象
53
+	 * 
54
+	 */
55
+	public static void remove() {
56
+		threadLocalSession.remove();
57
+
58
+	}
59
+	
60
+	
61
+}

+ 170 - 0
src/main/java/com/chinaitop/depot/storage/utils/ParameterUtil.java

@@ -0,0 +1,170 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import java.io.BufferedInputStream;
4
+import java.io.InputStream;
5
+import java.text.ParseException;
6
+import java.text.SimpleDateFormat;
7
+import java.util.Date;
8
+import java.util.List;
9
+import java.util.Properties;
10
+
11
+public class ParameterUtil {
12
+
13
+    public static String getSysDateTime(){
14
+        String temp_str="";
15
+        Date dt = new Date();
16
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
17
+        temp_str=sdf.format(dt);
18
+        System.out.println("获取当前时间"+temp_str);
19
+        return temp_str;
20
+    }
21
+    
22
+    public static String getDateYMDHMS(Date date) {
23
+    	String str = "";
24
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
25
+        str=sdf.format(date);
26
+        System.out.println("获取当前时间"+str);
27
+        return str;
28
+    }
29
+    
30
+    public static String getSysDate(){
31
+        String temp_str="";
32
+        Date dt = new Date();
33
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
34
+        temp_str=sdf.format(dt);
35
+        return temp_str;
36
+    }
37
+
38
+    public static Date string2datetime(String dateTime){
39
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
40
+        Date date = null;
41
+        try {
42
+            date = dateFormat.parse(dateTime);
43
+        } catch (ParseException e) {
44
+            e.printStackTrace();
45
+        }
46
+        return date;
47
+    }
48
+    public static Date string2date(String dateTime){
49
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
50
+        Date date = null;
51
+        try {
52
+            date = dateFormat.parse(dateTime);
53
+        } catch (ParseException e) {
54
+            e.printStackTrace();
55
+        }
56
+        return date;
57
+    }
58
+
59
+    public static String date2string(Date date){
60
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
61
+        String str=sdf.format(date);
62
+        return str;
63
+    }
64
+
65
+    /**
66
+     * 获取指定时间的时间戳
67
+     * @param datatime
68
+     * @return
69
+     */
70
+    public static String getTimeStamp(String datatime){
71
+        long timeStamp = 0;
72
+        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
73
+        try {
74
+            Date date = format.parse(datatime);
75
+            timeStamp = date.getTime();
76
+        } catch (ParseException e) {
77
+            e.printStackTrace();
78
+        }
79
+        return String.valueOf(timeStamp);
80
+    }
81
+
82
+    /*
83
+     * 将时间戳转换为时间
84
+     */
85
+    public static String stampToDate(String s){
86
+        String res;
87
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
88
+        long lt = new Long(s);
89
+        Date date = new Date(lt);
90
+        res = simpleDateFormat.format(date);
91
+        return res;
92
+    }
93
+
94
+    public static void main(String[] args) {
95
+        System.out.println(stampToDate("1504689208643"));
96
+        System.out.println(getTimeStamp(getSysDateTime()));
97
+    }
98
+    public static String getBHS(String BHS){
99
+        String[] str = BHS.split(",");
100
+        StringBuffer sb = new StringBuffer();
101
+        for(int i=0;i<str.length;i++){
102
+            sb.append("'").append(str[i]).append("'").append(",");
103
+        }
104
+        String s=sb.toString();
105
+        String t=s.substring(0,s.length()-1);
106
+        return t;
107
+    }
108
+
109
+    //判断字段值是为空 不为空返回ture
110
+    public static boolean isnotnull(Object name){
111
+        return (null!=name&&!"".equals(name) && !"null".equals(name) && "null" != name);
112
+    }
113
+    
114
+    //判断字段值是为空,为空返回ture
115
+    public static boolean isnull(Object name){
116
+        return (null==name || "".equals(name) || "null".equals(name) || "null" == name);
117
+    }
118
+
119
+    //判断字段值是相等  相等返回ture
120
+    public static boolean isequal(Object name,Object value){
121
+        if(name==value||name.equals(value)){
122
+            return true;
123
+        }
124
+        return false;
125
+    }
126
+
127
+    /**
128
+     * 判断list和str数组是否全等
129
+     * @param list
130
+     * @param str
131
+     * @return
132
+     */
133
+    public static boolean isAllequal(List<String> list,String[] str){
134
+        boolean isbz = true;
135
+        for(int z=0;z<str.length;z++){
136
+            if(!isequal(list.get(z),str[z])){
137
+                isbz = false;
138
+                break;
139
+            }
140
+        }
141
+        return !isbz || !(str.length == list.size());
142
+    }
143
+
144
+    //判断字段值是否在某个集合里  在返回ture
145
+    public static boolean isallequal(Object name,String[] value){
146
+        for(int i=0;i<value.length;i++){
147
+            if(name==value[i]||name.equals(value[i])){
148
+                return true;
149
+            }
150
+        }
151
+        return false;
152
+    }
153
+
154
+    /**
155
+     * 从properties得到路径
156
+     * @param filePath
157
+     * @return
158
+     */
159
+    public static Properties readProperties(String filePath) {
160
+        Properties props = new Properties();
161
+        try {
162
+            InputStream in = new BufferedInputStream(ParameterUtil.class.getResourceAsStream(filePath));
163
+            props.load(in);
164
+        } catch (Exception e) {
165
+            e.printStackTrace();
166
+        }
167
+        return props;
168
+    }
169
+
170
+}

+ 61 - 0
src/main/java/com/chinaitop/depot/storage/utils/RedisConfig.java

@@ -0,0 +1,61 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
4
+import com.fasterxml.jackson.annotation.PropertyAccessor;
5
+import com.fasterxml.jackson.databind.ObjectMapper;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.context.annotation.Bean;
8
+import org.springframework.context.annotation.Configuration;
9
+import org.springframework.data.redis.connection.RedisConnectionFactory;
10
+import org.springframework.data.redis.core.*;
11
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
12
+import org.springframework.data.redis.serializer.StringRedisSerializer;
13
+
14
+@Configuration
15
+public class RedisConfig {
16
+    @Autowired
17
+    private RedisConnectionFactory factory;
18
+
19
+    @Bean
20
+    public RedisTemplate<String, Object> redisTemplate() {
21
+        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
22
+        ObjectMapper om = new ObjectMapper();
23
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
24
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
25
+        jackson2JsonRedisSerializer.setObjectMapper(om);
26
+        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
27
+        template.setConnectionFactory(factory);
28
+        template.setKeySerializer(new StringRedisSerializer());
29
+        template.setValueSerializer(jackson2JsonRedisSerializer);
30
+        template.setHashKeySerializer(jackson2JsonRedisSerializer);
31
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
32
+        template.setDefaultSerializer(new StringRedisSerializer());
33
+        template.afterPropertiesSet();
34
+        return template;
35
+    }
36
+
37
+    @Bean
38
+    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
39
+        return redisTemplate.opsForHash();
40
+    }
41
+
42
+    @Bean
43
+    public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
44
+        return redisTemplate.opsForValue();
45
+    }
46
+
47
+    @Bean
48
+    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
49
+        return redisTemplate.opsForList();
50
+    }
51
+
52
+    @Bean
53
+    public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
54
+        return redisTemplate.opsForSet();
55
+    }
56
+
57
+    @Bean
58
+    public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
59
+        return redisTemplate.opsForZSet();
60
+    }
61
+}

+ 544 - 0
src/main/java/com/chinaitop/depot/storage/utils/RedisUtil.java

@@ -0,0 +1,544 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.data.redis.core.*;
5
+import org.springframework.stereotype.Component;
6
+import org.springframework.util.CollectionUtils;
7
+
8
+import java.util.List;
9
+import java.util.Map;
10
+import java.util.Set;
11
+import java.util.concurrent.TimeUnit;
12
+
13
+@Component
14
+public class RedisUtil {
15
+
16
+    @Autowired
17
+    private RedisTemplate<String, Object> redisTemplate;
18
+    @Autowired
19
+    private ValueOperations<String, String> valueOperations;
20
+    @Autowired
21
+    private HashOperations<String, String, Object> hashOperations;
22
+    @Autowired
23
+    private ListOperations<String, Object> listOperations;
24
+    @Autowired
25
+    private SetOperations<String, Object> setOperations;
26
+
27
+    //=============================common============================
28
+    /**
29
+     * 指定缓存失效时间
30
+     * @param key 键
31
+     * @param time 时间(秒)
32
+     * @return
33
+     */
34
+    public boolean expire(String key,long time){
35
+        try {
36
+            if(time>0){
37
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
38
+            }
39
+            return true;
40
+        } catch (Exception e) {
41
+            e.printStackTrace();
42
+            return false;
43
+        }
44
+    }
45
+
46
+    /**
47
+     * 根据key 获取过期时间
48
+     * @param key 键 不能为null
49
+     * @return 时间(秒) 返回0代表为永久有效
50
+     */
51
+    public long getExpire(String key){
52
+        return redisTemplate.getExpire(key,TimeUnit.SECONDS);
53
+    }
54
+
55
+    /**
56
+     * 判断key是否存在
57
+     * @param key 键
58
+     * @return true 存在 false不存在
59
+     */
60
+    public boolean hasKey(String key){
61
+        try {
62
+            return redisTemplate.hasKey(key);
63
+        } catch (Exception e) {
64
+            e.printStackTrace();
65
+            return false;
66
+        }
67
+    }
68
+
69
+    /**
70
+     * 删除缓存
71
+     * @param key 可以传一个值 或多个
72
+     */
73
+    @SuppressWarnings("unchecked")
74
+    public void del(String ... key){
75
+        if(key!=null&&key.length>0){
76
+            if(key.length==1){
77
+                redisTemplate.delete(key[0]);
78
+            }else{
79
+                redisTemplate.delete(CollectionUtils.arrayToList(key));
80
+            }
81
+        }
82
+    }
83
+
84
+    //============================String=============================
85
+    /**
86
+     * 普通缓存获取
87
+     * @param key 键
88
+     * @return 值
89
+     */
90
+    public Object get(String key){
91
+        return key==null?null:valueOperations.get(key);
92
+    }
93
+
94
+    /**
95
+     * 普通缓存放入
96
+     * @param key 键
97
+     * @param value 值
98
+     * @return true成功 false失败
99
+     */
100
+    public boolean set(String key,String value) {
101
+        try {
102
+            valueOperations.set(key, value);
103
+            return true;
104
+        } catch (Exception e) {
105
+            e.printStackTrace();
106
+            return false;
107
+        }
108
+
109
+    }
110
+
111
+    /**
112
+     * 普通缓存放入并设置时间
113
+     * @param key 键
114
+     * @param value 值
115
+     * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
116
+     * @return true成功 false 失败
117
+     */
118
+    public boolean set(String key,String value,long time){
119
+        try {
120
+            if(time>0){
121
+                valueOperations.set(key, value, time, TimeUnit.SECONDS);
122
+            }else{
123
+                set(key, value);
124
+            }
125
+            return true;
126
+        } catch (Exception e) {
127
+            e.printStackTrace();
128
+            return false;
129
+        }
130
+    }
131
+
132
+    /**
133
+     * 递增
134
+     * @param key 键
135
+     * @param by 要增加几(大于0)
136
+     * @return
137
+     */
138
+    public long incr(String key, long delta){
139
+        if(delta<0){
140
+            throw new RuntimeException("递增因子必须大于0");
141
+        }
142
+        return valueOperations.increment(key, delta);
143
+    }
144
+
145
+    /**
146
+     * 递减
147
+     * @param key 键
148
+     * @param by 要减少几(小于0)
149
+     * @return
150
+     */
151
+    public long decr(String key, long delta){
152
+        if(delta<0){
153
+            throw new RuntimeException("递减因子必须大于0");
154
+        }
155
+        return valueOperations.increment(key, -delta);
156
+    }
157
+
158
+    //================================Map=================================
159
+    /**
160
+     * HashGet
161
+     * @param key 键 不能为null
162
+     * @param item 项 不能为null
163
+     * @return 值
164
+     */
165
+    public Object hget(String key,String item){
166
+        return hashOperations.get(key, item);
167
+    }
168
+
169
+    /**
170
+     * 获取hashKey对应的所有键值
171
+     * @param key 键
172
+     * @return 对应的多个键值
173
+     */
174
+    public Map<String, Object> hmget(String key){
175
+        return hashOperations.entries(key);
176
+    }
177
+
178
+    /**
179
+     * HashSet
180
+     * @param key 键
181
+     * @param map 对应多个键值
182
+     * @return true 成功 false 失败
183
+     */
184
+    public boolean hmset(String key, Map<String,Object> map){
185
+        try {
186
+            hashOperations.putAll(key, map);
187
+            return true;
188
+        } catch (Exception e) {
189
+            e.printStackTrace();
190
+            return false;
191
+        }
192
+    }
193
+
194
+    /**
195
+     * HashSet 并设置时间
196
+     * @param key 键
197
+     * @param map 对应多个键值
198
+     * @param time 时间(秒)
199
+     * @return true成功 false失败
200
+     */
201
+    public boolean hmset(String key, Map<String,Object> map, long time){
202
+        try {
203
+            hashOperations.putAll(key, map);
204
+            if(time>0){
205
+                expire(key, time);
206
+            }
207
+            return true;
208
+        } catch (Exception e) {
209
+            e.printStackTrace();
210
+            return false;
211
+        }
212
+    }
213
+
214
+    /**
215
+     * 向一张hash表中放入数据,如果不存在将创建
216
+     * @param key 键
217
+     * @param item 项
218
+     * @param value 值
219
+     * @return true 成功 false失败
220
+     */
221
+    public boolean hset(String key,String item,Object value) {
222
+        try {
223
+            hashOperations.put(key, item, value);
224
+            return true;
225
+        } catch (Exception e) {
226
+            e.printStackTrace();
227
+            return false;
228
+        }
229
+    }
230
+
231
+    /**
232
+     * 向一张hash表中放入数据,如果不存在将创建
233
+     * @param key 键
234
+     * @param item 项
235
+     * @param value 值
236
+     * @param time 时间(秒)  注意:如果已存在的hash表有时间,这里将会替换原有的时间
237
+     * @return true 成功 false失败
238
+     */
239
+    public boolean hset(String key,String item,Object value,long time) {
240
+        try {
241
+            hashOperations.put(key, item, value);
242
+            if(time>0){
243
+                expire(key, time);
244
+            }
245
+            return true;
246
+        } catch (Exception e) {
247
+            e.printStackTrace();
248
+            return false;
249
+        }
250
+    }
251
+
252
+    /**
253
+     * 删除hash表中的值
254
+     * @param key 键 不能为null
255
+     * @param item 项 可以使多个 不能为null
256
+     */
257
+    public void hdel(String key, Object... item){
258
+        hashOperations.delete(key,item);
259
+    }
260
+
261
+    /**
262
+     * 判断hash表中是否有该项的值
263
+     * @param key 键 不能为null
264
+     * @param item 项 不能为null
265
+     * @return true 存在 false不存在
266
+     */
267
+    public boolean hHasKey(String key, String item){
268
+        return hashOperations.hasKey(key, item);
269
+    }
270
+
271
+    /**
272
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
273
+     * @param key 键
274
+     * @param item 项
275
+     * @param by 要增加几(大于0)
276
+     * @return
277
+     */
278
+    public double hincr(String key, String item,double by){
279
+        return hashOperations.increment(key, item, by);
280
+    }
281
+
282
+    /**
283
+     * hash递减
284
+     * @param key 键
285
+     * @param item 项
286
+     * @param by 要减少记(小于0)
287
+     * @return
288
+     */
289
+    public double hdecr(String key, String item,double by){
290
+        return hashOperations.increment(key, item,-by);
291
+    }
292
+
293
+    //============================set=============================
294
+    /**
295
+     * 根据key获取Set中的所有值
296
+     * @param key 键
297
+     * @return
298
+     */
299
+    public Set<Object> sGet(String key){
300
+        try {
301
+            return setOperations.members(key);
302
+        } catch (Exception e) {
303
+            e.printStackTrace();
304
+            return null;
305
+        }
306
+    }
307
+
308
+    /**
309
+     * 根据value从一个set中查询,是否存在
310
+     * @param key 键
311
+     * @param value 值
312
+     * @return true 存在 false不存在
313
+     */
314
+    public boolean sHasKey(String key,Object value){
315
+        try {
316
+            return setOperations.isMember(key, value);
317
+        } catch (Exception e) {
318
+            e.printStackTrace();
319
+            return false;
320
+        }
321
+    }
322
+
323
+    /**
324
+     * 将数据放入set缓存
325
+     * @param key 键
326
+     * @param values 值 可以是多个
327
+     * @return 成功个数
328
+     */
329
+    public long sSet(String key, Object...values) {
330
+        try {
331
+            return setOperations.add(key, values);
332
+        } catch (Exception e) {
333
+            e.printStackTrace();
334
+            return 0;
335
+        }
336
+    }
337
+
338
+    /**
339
+     * 将set数据放入缓存
340
+     * @param key 键
341
+     * @param time 时间(秒)
342
+     * @param values 值 可以是多个
343
+     * @return 成功个数
344
+     */
345
+    public long sSetAndTime(String key,long time,Object...values) {
346
+        try {
347
+            Long count = setOperations.add(key, values);
348
+            if(time>0) expire(key, time);
349
+            return count;
350
+        } catch (Exception e) {
351
+            e.printStackTrace();
352
+            return 0;
353
+        }
354
+    }
355
+
356
+    /**
357
+     * 获取set缓存的长度
358
+     * @param key 键
359
+     * @return
360
+     */
361
+    public long sGetSetSize(String key){
362
+        try {
363
+            return setOperations.size(key);
364
+        } catch (Exception e) {
365
+            e.printStackTrace();
366
+            return 0;
367
+        }
368
+    }
369
+
370
+    /**
371
+     * 移除值为value的
372
+     * @param key 键
373
+     * @param values 值 可以是多个
374
+     * @return 移除的个数
375
+     */
376
+    public long setRemove(String key, Object ...values) {
377
+        try {
378
+            Long count = setOperations.remove(key, values);
379
+            return count;
380
+        } catch (Exception e) {
381
+            e.printStackTrace();
382
+            return 0;
383
+        }
384
+    }
385
+    //===============================list=================================
386
+
387
+    /**
388
+     * 获取list缓存的内容
389
+     * @param key 键
390
+     * @param start 开始
391
+     * @param end 结束  0 到 -1代表所有值
392
+     * @return
393
+     */
394
+    public List<Object> lGet(String key, long start, long end){
395
+        try {
396
+            return listOperations.range(key, start, end);
397
+        } catch (Exception e) {
398
+            e.printStackTrace();
399
+            return null;
400
+        }
401
+    }
402
+
403
+    /**
404
+     * 获取list缓存的所有内容
405
+     * @param key
406
+     * @return
407
+     */
408
+    public List<Object> lGetAll(String key){
409
+        return lGet(key,0,-1);
410
+    }
411
+
412
+    /**
413
+     * 获取list缓存的长度
414
+     * @param key 键
415
+     * @return
416
+     */
417
+    public long lGetListSize(String key){
418
+        try {
419
+            return listOperations.size(key);
420
+        } catch (Exception e) {
421
+            e.printStackTrace();
422
+            return 0;
423
+        }
424
+    }
425
+
426
+    /**
427
+     * 通过索引 获取list中的值
428
+     * @param key 键
429
+     * @param index 索引  index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
430
+     * @return
431
+     */
432
+    public Object lGetIndex(String key,long index){
433
+        try {
434
+            return listOperations.index(key, index);
435
+        } catch (Exception e) {
436
+            e.printStackTrace();
437
+            return null;
438
+        }
439
+    }
440
+
441
+    /**
442
+     * 将list放入缓存
443
+     * @param key 键
444
+     * @param value 值
445
+     * @param time 时间(秒)
446
+     * @return
447
+     */
448
+    public boolean lSet(String key, Object value) {
449
+        try {
450
+            listOperations.rightPush(key, value);
451
+            return true;
452
+        } catch (Exception e) {
453
+            e.printStackTrace();
454
+            return false;
455
+        }
456
+    }
457
+
458
+    /**
459
+     * 将list放入缓存
460
+     * @param key 键
461
+     * @param value 值
462
+     * @param time 时间(秒)
463
+     * @return
464
+     */
465
+    public boolean lSet(String key, Object value, long time) {
466
+        try {
467
+            listOperations.rightPush(key, value);
468
+            if (time > 0) expire(key, time);
469
+            return true;
470
+        } catch (Exception e) {
471
+            e.printStackTrace();
472
+            return false;
473
+        }
474
+    }
475
+
476
+    /**
477
+     * 将list放入缓存
478
+     * @param key 键
479
+     * @param value 值
480
+     * @param time 时间(秒)
481
+     * @return
482
+     */
483
+    public boolean lSet(String key, List<Object> value) {
484
+        try {
485
+            listOperations.rightPushAll(key, value);
486
+            return true;
487
+        } catch (Exception e) {
488
+            e.printStackTrace();
489
+            return false;
490
+        }
491
+    }
492
+
493
+    /**
494
+     * 将list放入缓存
495
+     * @param key 键
496
+     * @param value 值
497
+     * @param time 时间(秒)
498
+     * @return
499
+     */
500
+    public boolean lSet(String key, List<Object> value, long time) {
501
+        try {
502
+            listOperations.rightPushAll(key, value);
503
+            if (time > 0) expire(key, time);
504
+            return true;
505
+        } catch (Exception e) {
506
+            e.printStackTrace();
507
+            return false;
508
+        }
509
+    }
510
+
511
+    /**
512
+     * 根据索引修改list中的某条数据
513
+     * @param key 键
514
+     * @param index 索引
515
+     * @param value 值
516
+     * @return
517
+     */
518
+    public boolean lUpdateIndex(String key, long index,Object value) {
519
+        try {
520
+            listOperations.set(key, index, value);
521
+            return true;
522
+        } catch (Exception e) {
523
+            e.printStackTrace();
524
+            return false;
525
+        }
526
+    }
527
+
528
+    /**
529
+     * 移除N个值为value
530
+     * @param key 键
531
+     * @param count 移除多少个
532
+     * @param value 值
533
+     * @return 移除的个数
534
+     */
535
+    public long lRemove(String key,long count,Object value) {
536
+        try {
537
+            Long remove = listOperations.remove(key, count, value);
538
+            return remove;
539
+        } catch (Exception e) {
540
+            e.printStackTrace();
541
+            return 0;
542
+        }
543
+    }
544
+}

+ 40 - 0
src/main/java/com/chinaitop/depot/storage/utils/WebConfig.java

@@ -0,0 +1,40 @@
1
+package com.chinaitop.depot.storage.utils;
2
+
3
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+
7
+import java.util.ArrayList;
8
+import java.util.List;
9
+
10
+/**
11
+ * @desc 注册bean, 将自定义过滤器添加到过滤器链中
12
+ * @Author hf
13
+ * @date 2019/3/11
14
+ * @return
15
+ */
16
+@Configuration
17
+public class WebConfig {
18
+
19
+   /**
20
+    * 注册过滤器,有两种方式:
21
+    * 1) 使用 @Component 注解<br>
22
+    * 2) 添加到过滤器链中,此方式适用于使用第三方的过滤器。将过滤器写到 WebConfig 类中,如下:
23
+    */
24
+   @Bean
25
+   public FilterRegistrationBean filterRegistrationBean() {
26
+
27
+      FilterRegistrationBean registrationBean = new FilterRegistrationBean();
28
+
29
+      CustomFilter filter = new CustomFilter();
30
+      registrationBean.setFilter(filter);
31
+
32
+      //设置过滤器拦截请求
33
+      List<String> urls = new ArrayList<>();
34
+      urls.add("/*");
35
+      registrationBean.setUrlPatterns(urls);
36
+
37
+      return registrationBean;
38
+   }
39
+
40
+}

+ 47 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,47 @@
1
+server:
2
+  port: 9015
3
+  tomcat:
4
+    uri-encoding: utf-8
5
+
6
+# 注册中心配置
7
+eureka:
8
+  client:
9
+    service-url:
10
+      defaultZone: http://localhost:9001/eureka/
11
+  instance:
12
+    prefer-ip-address: true
13
+
14
+spring:
15
+  application:
16
+    name: depot-payment
17
+  # 数据库配置
18
+  datasource:
19
+    driver-class-name: com.mysql.jdbc.Driver
20
+    url: jdbc:mysql://192.168.123.98:3306/depot?useUnicode=true&characterEncoding=utf-8
21
+    username: root
22
+    password: 123456
23
+  # 缓存配置
24
+  session:
25
+    store-type: redis
26
+  redis:
27
+    database: 0
28
+    host: 192.168.123.98
29
+    port: 6666
30
+    password: depotredis
31
+    timeout: 3000
32
+    jedis:
33
+      pool:
34
+        max-active: 8
35
+        max-wait: -1
36
+        max-idle: 8
37
+        min-idle: 0
38
+  # 静态资源配置
39
+  resources:
40
+    static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path}
41
+
42
+web:
43
+  upload-path: /home
44
+
45
+  jackson:
46
+    date-format: yyyy-MM-dd
47
+    time-zone: GMT+8

+ 16 - 0
src/test/java/com/chinaitop/DepotPaymentApplicationTests.java

@@ -0,0 +1,16 @@
1
+package com.chinaitop;
2
+
3
+import org.junit.Test;
4
+import org.junit.runner.RunWith;
5
+import org.springframework.boot.test.context.SpringBootTest;
6
+import org.springframework.test.context.junit4.SpringRunner;
7
+
8
+@RunWith(SpringRunner.class)
9
+@SpringBootTest
10
+public class DepotPaymentApplicationTests {
11
+
12
+	@Test
13
+	public void contextLoads() {
14
+	}
15
+
16
+}