diff --git a/README.en.md b/README.en.md
deleted file mode 100644
index f5d1f09cb60df263dd09ade2bac92919584d19e9..0000000000000000000000000000000000000000
--- a/README.en.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# 消费明细君后台
-
-#### Description
-统计日常消费后台
-
-#### Software Architecture
-Software architecture description
-
-#### Installation
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Instructions
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Contribution
-
-1. Fork the repository
-2. Create Feat_xxx branch
-3. Commit your code
-4. Create Pull Request
-
-
-#### Gitee Feature
-
-1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
-2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
-3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
-4. The most valuable open source project [GVP](https://gitee.com/gvp)
-5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
-6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
\ No newline at end of file
diff --git a/README.md b/README.md
index c9eeaa01024276c823cf269c5a7b57dd71a0c818..7150d6a39e4af6d106086dfe2b5a46c493ea94a4 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# 消费明细君后台
#### 介绍
-统计日常消费后台
+这个是消费明细君后台接口
#### 软件架构
软件架构说明
diff --git a/doc/consume.sql b/doc/consume.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a2d2b9b25f4ea952468ef9f526d97ab98640ec2b
--- /dev/null
+++ b/doc/consume.sql
@@ -0,0 +1,258 @@
+/*
+Navicat MySQL Data Transfer
+
+Source Server : root@47.93.196.206
+Source Server Version : 50645
+Source Host : 47.93.196.206:3306
+Source Database : consume-dev
+
+Target Server Type : MYSQL
+Target Server Version : 50645
+File Encoding : 65001
+
+Date: 2020-01-12 17:05:12
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+
+-- ----------------------------
+-- Table structure for t_access_token
+-- ----------------------------
+DROP TABLE IF EXISTS `t_access_token`;
+CREATE TABLE `t_access_token` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `access_token` varchar(255) DEFAULT NULL COMMENT '微信accessToken',
+ `expires_in` int(11) DEFAULT '0' COMMENT 'token有效时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='accessToken';
+
+-- ----------------------------
+-- Table structure for t_assets
+-- ----------------------------
+DROP TABLE IF EXISTS `t_assets`;
+CREATE TABLE `t_assets` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `total_money` bigint(20) DEFAULT NULL COMMENT '总金额',
+ `total_expenditure` bigint(20) DEFAULT NULL COMMENT '总支出',
+ `total_income` bigint(20) DEFAULT NULL COMMENT '总收入',
+ `user_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
+ PRIMARY KEY (`id`),
+ KEY `user_id` (`user_id`),
+ CONSTRAINT `t_assets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `t_wx_user` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COMMENT='用户资产表';
+
+-- ----------------------------
+-- Table structure for t_assets_detail
+-- ----------------------------
+DROP TABLE IF EXISTS `t_assets_detail`;
+CREATE TABLE `t_assets_detail` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `month_total_money` bigint(20) DEFAULT NULL COMMENT '月总金额',
+ `month_total_expenditure` bigint(20) DEFAULT NULL COMMENT '月总支出',
+ `month_total_income` bigint(20) DEFAULT NULL COMMENT '月总收入',
+ `now_month` varchar(20) NOT NULL DEFAULT '0' COMMENT '当前月份',
+ `now_first_month` bigint(20) NOT NULL DEFAULT '0' COMMENT '当前月份初始时间时间戳',
+ `user_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
+ `assets_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '资产表id',
+ PRIMARY KEY (`id`),
+ KEY `user_id` (`user_id`),
+ KEY `assets_id` (`assets_id`),
+ CONSTRAINT `t_assets_detail_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `t_wx_user` (`id`),
+ CONSTRAINT `t_assets_detail_ibfk_2` FOREIGN KEY (`assets_id`) REFERENCES `t_assets` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COMMENT='用户资产明细表';
+
+-- ----------------------------
+-- Table structure for t_bookkeeping
+-- ----------------------------
+DROP TABLE IF EXISTS `t_bookkeeping`;
+CREATE TABLE `t_bookkeeping` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `money` bigint(20) NOT NULL DEFAULT '0' COMMENT '消费金额',
+ `consume_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '消费日期',
+ `consume_type_id` bigint(20) unsigned NOT NULL COMMENT '消费类型id',
+ `user_id` bigint(20) unsigned NOT NULL COMMENT '用户id',
+ `is_show_time` int(11) NOT NULL DEFAULT '0' COMMENT '前端判断是否显示消费时间',
+ `image_url` text COMMENT '图片List保存',
+ `address` varchar(255) DEFAULT NULL COMMENT '消费地址',
+ `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
+ `consume_time_day` bigint(20) DEFAULT '0' COMMENT '消费的日期,取当天凌晨时间戳',
+ `address_detail` varchar(255) DEFAULT '' COMMENT '详情地址信息',
+ PRIMARY KEY (`id`),
+ KEY `user_id` (`user_id`),
+ KEY `consume_type_id` (`consume_type_id`),
+ CONSTRAINT `t_bookkeeping_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `t_wx_user` (`id`),
+ CONSTRAINT `t_bookkeeping_ibfk_2` FOREIGN KEY (`consume_type_id`) REFERENCES `t_consume_type` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=272 DEFAULT CHARSET=utf8 COMMENT='记账表';
+
+-- ----------------------------
+-- Table structure for t_city
+-- ----------------------------
+DROP TABLE IF EXISTS `t_city`;
+CREATE TABLE `t_city` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `city` varchar(20) DEFAULT NULL COMMENT '城市',
+ `area` varchar(20) DEFAULT NULL COMMENT '市区',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COMMENT='城市信息表';
+
+-- ----------------------------
+-- Table structure for t_city_weather
+-- ----------------------------
+DROP TABLE IF EXISTS `t_city_weather`;
+CREATE TABLE `t_city_weather` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `weather_result_json` longtext NOT NULL COMMENT '和风天气返回的json数据',
+ `weather_type` varchar(20) NOT NULL DEFAULT '0' COMMENT '天气数据类型 now:实况天气 forecast:3-10天预报 hourly:逐小时预报 lifestyle:生活指数',
+ `city_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '城市id',
+ PRIMARY KEY (`id`),
+ KEY `city_id` (`city_id`),
+ CONSTRAINT `t_city_weather_ibfk_1` FOREIGN KEY (`city_id`) REFERENCES `t_city` (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='城市-天气信息表';
+
+-- ----------------------------
+-- Table structure for t_consume_type
+-- ----------------------------
+DROP TABLE IF EXISTS `t_consume_type`;
+CREATE TABLE `t_consume_type` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `icon` varchar(255) DEFAULT NULL COMMENT 'icon地址',
+ `name` varchar(255) DEFAULT NULL COMMENT '名称',
+ `type` int(11) NOT NULL DEFAULT '0' COMMENT '消费类型 0:支出 1:收入',
+ `icon_1` varchar(255) DEFAULT NULL COMMENT 'icon_1地址',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COMMENT='消费类型表';
+
+-- ----------------------------
+-- Table structure for t_wx_form_id
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_form_id`;
+CREATE TABLE `t_wx_form_id` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `form_id` varchar(255) DEFAULT NULL COMMENT 'formId',
+ `open_id` varchar(255) DEFAULT NULL COMMENT '微信openId',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=200 DEFAULT CHARSET=utf8 COMMENT='模型消息表达formId';
+
+-- ----------------------------
+-- Table structure for t_wx_subscribe
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_subscribe`;
+CREATE TABLE `t_wx_subscribe` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `subscribe_id` varchar(255) DEFAULT NULL COMMENT '订阅id',
+ `name` varchar(255) DEFAULT NULL COMMENT '模板名称',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `subscribe_id` (`subscribe_id`),
+ KEY `subscribe_id_2` (`subscribe_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COMMENT='订阅消息';
+
+-- ----------------------------
+-- Table structure for t_wx_template
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_template`;
+CREATE TABLE `t_wx_template` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `template_id` varchar(255) DEFAULT NULL COMMENT '模板id',
+ `name` varchar(255) DEFAULT NULL COMMENT '模板名称',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `template_id` (`template_id`),
+ KEY `template_id_2` (`template_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COMMENT='订阅消息模板消息';
+
+-- ----------------------------
+-- Table structure for t_wx_user
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_user`;
+CREATE TABLE `t_wx_user` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `username` varchar(20) DEFAULT NULL COMMENT '用户账号',
+ `nick_name` varchar(255) DEFAULT NULL COMMENT '用户昵称',
+ `phone` int(11) DEFAULT NULL COMMENT '电话',
+ `avatar_url` varchar(255) DEFAULT NULL COMMENT '用户头像',
+ `rights` int(11) NOT NULL DEFAULT '0' COMMENT '类型:0用户 1管理员',
+ `login_end_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '最后登录时间',
+ `open_id` varchar(255) DEFAULT NULL COMMENT 'openId',
+ `month_budget` bigint(20) DEFAULT '0' COMMENT '月预算',
+ `send_message` smallint(1) NOT NULL DEFAULT '0' COMMENT '是否发送模板消息 0:不发送 1:发送',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8 COMMENT='微信用户表';
+
+-- ----------------------------
+-- Table structure for t_wx_user_subscribe
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_user_subscribe`;
+CREATE TABLE `t_wx_user_subscribe` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `subscribe_id` varchar(255) DEFAULT NULL COMMENT '模板id',
+ `user_id` bigint(20) unsigned NOT NULL COMMENT '用户id',
+ `type` int(1) DEFAULT NULL COMMENT '授权状态: 0:拒绝 1:允许 2:后台封禁',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `subscribe_id` (`subscribe_id`,`user_id`),
+ KEY `subscribe_id_2` (`subscribe_id`,`user_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8 COMMENT='用户订阅消息';
+
+-- ----------------------------
+-- Table structure for t_wx_user_template
+-- ----------------------------
+DROP TABLE IF EXISTS `t_wx_user_template`;
+CREATE TABLE `t_wx_user_template` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '表主键',
+ `create_time` bigint(20) DEFAULT '0' COMMENT '添加时间',
+ `update_time` bigint(20) DEFAULT '0' COMMENT '更新时间',
+ `enabled` int(1) DEFAULT '1' COMMENT '是否可见,0为不可见,1为可见',
+ `weight` bigint(20) DEFAULT '0' COMMENT '权重',
+ `template_id` varchar(255) DEFAULT NULL COMMENT '模板id',
+ `user_id` bigint(20) unsigned NOT NULL COMMENT '用户id',
+ `type` varchar(255) DEFAULT NULL COMMENT '授权状态: 0:拒绝 1:允许 2:后台封禁',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `template_id` (`template_id`,`user_id`),
+ KEY `template_id_2` (`template_id`,`user_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COMMENT='订阅消息模板消息';
diff --git a/doc/insert.sql b/doc/insert.sql
new file mode 100644
index 0000000000000000000000000000000000000000..016165408ff8105582da525a934f47cd6bc33b06
--- /dev/null
+++ b/doc/insert.sql
@@ -0,0 +1,22 @@
+INSERT INTO `t_consume_type` VALUES ('1', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/yule.png', '娱乐', '0', 'images/consume/icon/yule_1.png');
+INSERT INTO `t_consume_type` VALUES ('2', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/yiliao.png', '医疗', '0', 'images/consume/icon/yiliao_1.png');
+INSERT INTO `t_consume_type` VALUES ('3', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/touzi.png', '投资', '0', 'images/consume/icon/touzi_1.png');
+INSERT INTO `t_consume_type` VALUES ('4', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/shuiguo.png', '水果', '0', 'images/consume/icon/shuiguo_1.png');
+INSERT INTO `t_consume_type` VALUES ('5', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/shuidian.png', '水电', '0', 'images/consume/icon/shuidian_1.png');
+INSERT INTO `t_consume_type` VALUES ('6', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/jiaotong.png', '交通', '0', 'images/consume/icon/jiaotong_1.png');
+INSERT INTO `t_consume_type` VALUES ('7', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/huafei.png', '话费', '0', 'images/consume/icon/huafei_1.png');
+INSERT INTO `t_consume_type` VALUES ('8', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/fangzu.png', '房租', '0', 'images/consume/icon/fangzu_1.png');
+INSERT INTO `t_consume_type` VALUES ('9', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/chihe.png', '吃喝', '0', 'images/consume/icon/chihe_1.png');
+INSERT INTO `t_consume_type` VALUES ('18', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/gongzi.png', '工资', '1', 'images/consume/icon/gongzi_1.png');
+INSERT INTO `t_consume_type` VALUES ('19', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/jianzhi.png', '兼职', '1', 'images/consume/icon/jianzhi_1.png');
+INSERT INTO `t_consume_type` VALUES ('20', '1565415733306', '1565415733306', '1', '1565415733306', 'images/consume/icon/shoukuan.png', '收款', '1', 'images/consume/icon/shoukuan_1.png');
+
+
+
+ALTER TABLE `t_bookkeeping` ADD COLUMN `consume_time_day` BIGINT DEFAULT 0 COMMENT '消费的日期,取当天凌晨时间戳';
+ALTER TABLE `t_bookkeeping` ADD COLUMN `address_detail` VARCHAR(255) DEFAULT '' COMMENT '详情地址信息';
+
+
+INSERT INTO `t_wx_subscribe` VALUES ('1', '1578735039288', '1578735039288', '1', '1565415733306', 'nlD1JNUEtWlHjUiqcNFOYJQBG-akvOSbST0b0aWllOs', '记账成功提醒');
+INSERT INTO `t_wx_subscribe` VALUES ('2', '1578735039288', '1578735039288', '1', '1565415733306', '9idG4F8CNOaiGOo5EYwqB4wxVx8QXtoSg1HjNMnlM4M', '记账预算提醒');
+INSERT INTO `t_wx_subscribe` VALUES ('3', '1578735039288', '1578735039288', '1', '1565415733306', 'e5WNxg6ppcab2LvQTHVPutAlb6BJYAzheIkauWkWS1Q', '版本更新通知');
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..03592dde883244bb422f9fd93e0c12eaae154fc9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,131 @@
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.2.RELEASE
+
+
+
+ com.consume
+ consume-be
+ 1.0-SNAPSHOT
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ com.alibaba
+ druid
+ 1.1.9
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.44
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.15
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.2.2
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.2.2
+
+
+
+
+ com.auth0
+ java-jwt
+ 3.4.0
+
+
+ org.springframework
+ spring-test
+ 5.1.4.RELEASE
+ compile
+
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.3.5
+
+
+
+ commons-httpclient
+ commons-httpclient
+ 3.1
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.1
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+
+ commons-codec
+ commons-codec
+ 1.9
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/cloud/ConsumeApplication.java b/src/main/java/com/cloud/ConsumeApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..163ed71c8bd40b249a7bd50e731e49b76e7d3d93
--- /dev/null
+++ b/src/main/java/com/cloud/ConsumeApplication.java
@@ -0,0 +1,15 @@
+package com.cloud;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@SpringBootApplication
+@EnableScheduling
+@EnableSwagger2
+public class ConsumeApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ConsumeApplication.class,args);
+ }
+}
diff --git a/src/main/java/com/cloud/commons/constants/ConsumeConstant.java b/src/main/java/com/cloud/commons/constants/ConsumeConstant.java
new file mode 100644
index 0000000000000000000000000000000000000000..86ecc3275ce5706ad5aeeaf221a52ea4b362adf1
--- /dev/null
+++ b/src/main/java/com/cloud/commons/constants/ConsumeConstant.java
@@ -0,0 +1,41 @@
+package com.cloud.commons.constants;
+
+public class ConsumeConstant {
+ // 启用
+ public static final Integer ENABLED = 1;
+
+ // 禁用
+ public static final Integer DISABLED = 0;
+
+ // 删除
+ public static final Integer DELETE = 4;
+
+ // 初始化金额为
+ public static final Long MONRY_INIT = 0L;
+
+ //默认备注信息
+ public static final String REMART = "这笔消费暂无备注信息";
+
+ //格式化金额
+ public static final String DATE_FORMAT = "yyyy年MM月dd日";
+
+ public static final String DATE_TIME_FORMAT = "yyyy-MM-dd";
+
+ //支出
+ public static final Integer PAY = 0;
+
+ //收入
+ public static final Integer INCOME = 1;
+
+ //消费成功订阅消息
+ public static final String BOOKKEEPING_SUCCESS = "nlD1JNUEtWlHjUiqcNFOYJQBG-akvOSbST0b0aWllOs";
+ // 记账预算提醒模板消息
+ public static final String ACCOUNTING_BUDGET = "9idG4F8CNOaiGOo5EYwqB4wxVx8QXtoSg1HjNMnlM4M";
+ //版本更新模板消息
+ public static final String UPDATE_VERSION = "e5WNxg6ppcab2LvQTHVPutAlb6BJYAzheIkauWkWS1Q";
+
+ // 订阅消息状态 允许
+ public static final Integer SUBSCRIBE_SUCCESS = 1;
+
+
+}
diff --git a/src/main/java/com/cloud/commons/utils/CloudCopyUtils.java b/src/main/java/com/cloud/commons/utils/CloudCopyUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3f9da319c8de74b86444cbe05dfb2fa03cba593
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/CloudCopyUtils.java
@@ -0,0 +1,31 @@
+package com.cloud.commons.utils;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CloudCopyUtils {
+ private static String[] getNullPropertyNames (Object source) {
+ final BeanWrapper src = new BeanWrapperImpl(source);
+ java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
+
+ Set emptyNames = new HashSet();
+ for(java.beans.PropertyDescriptor pd : pds) {
+ Object srcValue = src.getPropertyValue(pd.getName());
+ if (srcValue == null) emptyNames.add(pd.getName());
+ }
+ String[] result = new String[emptyNames.size()];
+ return emptyNames.toArray(result);
+ }
+
+ public static void copyBean(Object src, Object target) {
+ BeanUtils.copyProperties(src,target);
+ }
+
+ public static void copyBeanExcludeNull(Object src, Object target) {
+ BeanUtils.copyProperties(src, target, getNullPropertyNames(src));
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/CloudDateUtils.java b/src/main/java/com/cloud/commons/utils/CloudDateUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..73d640e2d7f43f6ecca2b9181ea180a7c457c2f4
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/CloudDateUtils.java
@@ -0,0 +1,254 @@
+package com.cloud.commons.utils;
+
+import org.springframework.util.StringUtils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+
+public class CloudDateUtils {
+
+ private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+ /**
+ * 获得本周一与当前日期相差的天数
+ *
+ * @return
+ */
+ public static int getMondayPlus() {
+ Calendar cd = Calendar.getInstance();
+ int dayOfWeek = cd.get(Calendar.DAY_OF_WEEK);
+ if (dayOfWeek == 1) {
+ return -6;
+ } else {
+ return 2 - dayOfWeek;
+ }
+ }
+
+ /**
+ * 获取当天凌晨时间戳
+ * @return
+ */
+ public static Long getCurrentDayStartTime() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ Long start = calendar.getTimeInMillis();
+ return start;
+ }
+
+ /**
+ * 获取当天23点时间戳
+ * @return
+ */
+ public static Long getCurrentDayEndTime() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY,23);
+ calendar.set(Calendar.MINUTE,59);
+ calendar.set(Calendar.SECOND,59);
+ Long endTime = calendar.getTimeInMillis();
+ return endTime;
+ }
+
+ /**
+ * 获得当前周- 周一的日期
+ *
+ * @return
+ */
+ public static Long getCurrentMonday() {
+ int mondayPlus = getMondayPlus();
+ GregorianCalendar currentDate = new GregorianCalendar();
+ currentDate.add(GregorianCalendar.DATE, mondayPlus);
+ //将时、分、秒、毫秒 清零
+ currentDate.set(Calendar.HOUR_OF_DAY, 0);
+ currentDate.set(Calendar.MINUTE, 0);
+ currentDate.set(Calendar.SECOND, 0);
+ currentDate.set(Calendar.MILLISECOND, 0);
+ Date monday = currentDate.getTime();
+ Long preMonday = monday.getTime();
+
+ return preMonday;
+ }
+
+
+ /**
+ * 获得当前周- 周日 的日期
+ *
+ * @return
+ */
+ public static Long getCurrentSunday() {
+ int mondayPlus = getMondayPlus();
+ GregorianCalendar currentDate = new GregorianCalendar();
+ currentDate.add(GregorianCalendar.DATE, mondayPlus + 6);
+ //将时、分、秒、毫秒 清零
+ currentDate.set(Calendar.HOUR_OF_DAY, 0);
+ currentDate.set(Calendar.MINUTE, 0);
+ currentDate.set(Calendar.SECOND, 0);
+ currentDate.set(Calendar.MILLISECOND, 0);
+ Date sunday = currentDate.getTime();
+ Long preSunday = sunday.getTime();
+ return preSunday;
+ }
+
+ /**
+ * 获得当前月--开始日期
+ *
+ * @return
+ */
+ public static Long getCurrentMonthFirstDay() {
+ Calendar calendar = Calendar.getInstance();
+ calendar = Calendar.getInstance();
+ calendar.add(Calendar.MONTH, 0);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ //将时、分、秒、毫秒 清零
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ return calendar.getTime().getTime();
+ }
+
+ /**
+ * 获得当前月--结束日期
+ *
+ * @return
+ */
+ public static Long getCurrentMonthLastDay() {
+ Calendar calendar = Calendar.getInstance();
+ calendar = Calendar.getInstance();
+ calendar.add(Calendar.MONTH, 1);
+ calendar.set(Calendar.DAY_OF_MONTH, 0);
+ //将时、分、秒、毫秒 清零
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ return calendar.getTime().getTime();
+ }
+
+ // 日期转字符串格式
+ public static String timeStamp2Date(String seconds, String format) {
+ if (StringUtils.isEmpty(seconds) || StringUtils.isEmpty(format)) {
+
+ }
+ if (format == null || format.isEmpty()) {
+ format = "yyyy-MM-dd HH:mm:ss";
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ return sdf.format(new Date(Long.valueOf(seconds)));
+ }
+
+ // 字符串转日期格式
+ public static Date StrToDate(String str, String formatString) {
+
+ if (formatString == null || formatString.isEmpty()) {
+ formatString = "yyyy-MM-dd HH:mm:ss";
+ }
+ SimpleDateFormat format = new SimpleDateFormat(formatString);
+
+ Date date = null;
+ try {
+ date = format.parse(str);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return date;
+ }
+
+ /**
+ * 获取给定时间 当天0点的时间戳
+ *
+ * @param time
+ * @return
+ */
+ public static Long getDayStartTime(Long time) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date(time));
+
+ //将时、分、秒、毫秒 清零
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ return calendar.getTime().getTime();
+ }
+
+ /**
+ * 获取给定时间 当天24点的时间戳
+ *
+ * @param time
+ * @return
+ */
+ public static Long getDayEndTime(Long time) {
+ Long startTime = getDayStartTime(time);
+ Long oneDayTimeMillis = 60000 * 60 * 24L;
+ return startTime + oneDayTimeMillis;
+ }
+
+ /**
+ * 获取倒计时
+ * @param time
+ * @return
+ */
+ public static String getTimeCountDown(Long time){
+
+ long nd = 1000*24*60*60;//一天的毫秒数
+ long nh = 1000*60*60;//一小时的毫秒数
+ long nm = 1000*60;//一分钟的毫秒数
+ long ns = 1000;//一秒钟的毫秒数
+
+ long day = time/nd;//计算差多少天
+ long hour = time%nd/nh;//计算差多少小时
+ long min = time%nd%nh/nm;//计算差多少分钟
+ long sec = time%nd%nh%nm/ns;//计算差多少秒
+ return day+"天"+(hour<10?"0"+hour:hour)+"时"+(min<10?"0"+min:min)+"分"+(sec<10?"0"+sec:sec)+"秒";
+ }
+
+
+ /**
+ * 获取过去第几天的时间戳
+ *
+ * @param past
+ * @return
+ */
+ public static Long getPastDate(int past){
+ Long OneWeekTime = System.currentTimeMillis();
+ if (past > 0){
+ OneWeekTime = OneWeekTime - (86400000 * past);
+ }else if (past < 0){
+ System.out.println("参数不对");
+ OneWeekTime = null;
+ }
+
+ return OneWeekTime;
+ }
+
+
+
+ /**
+ * 获取当前日期是星期几
+ *
+ * @param dt
+ * @return 当前日期是星期几
+ */
+ public static String getWeekOfDate(Date dt) {
+ String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dt);
+ int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+ if (w < 0)
+ w = 0;
+ return weekDays[w];
+ }
+
+
+}
diff --git a/src/main/java/com/cloud/commons/utils/DateUtils.java b/src/main/java/com/cloud/commons/utils/DateUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..b793f676dabf48a3b818b2d10ebf656e706a3e29
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/DateUtils.java
@@ -0,0 +1,198 @@
+package com.cloud.commons.utils;
+
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+public class DateUtils {
+
+ /**
+ * 获取当天凌晨时间戳
+ * @return
+ */
+ public static Long getCurrentDayStartTime() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ Long start = calendar.getTimeInMillis();
+ return start;
+ }
+
+ /**
+ * 获取当天23点时间戳
+ * @return
+ */
+ public static Long getCurrentDayEndTime() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date());
+ calendar.set(Calendar.HOUR_OF_DAY,23);
+ calendar.set(Calendar.MINUTE,59);
+ calendar.set(Calendar.SECOND,59);
+ Long endTime = calendar.getTimeInMillis();
+ return endTime;
+ }
+
+ /**
+ * 获取当前年-月份
+ */
+ public static String getYearAndMonth(Long valueTime) {
+ if (ObjectUtils.isEmpty(valueTime)) {
+ throw new RuntimeException("获取不到有效时间:" + valueTime);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(valueTime);
+ return calendar.get(Calendar.YEAR) +"/"+ calendar.get(Calendar.MONTH) + 1;
+ }
+
+
+ /**
+ * 获取指定日期当前月-开始时间
+ */
+ public static Long getCurrentMonthFirstDay(Long valueTime){
+ if (ObjectUtils.isEmpty(valueTime)) {
+ throw new RuntimeException("获取不到有效时间" + valueTime);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(valueTime);
+ calendar.set(Calendar.DATE,1);
+ calendar.set(Calendar.HOUR_OF_DAY,0);
+ calendar.set(Calendar.MINUTE,0);
+ calendar.set(Calendar.SECOND,0);
+ calendar.set(Calendar.MILLISECOND,0);
+ return calendar.getTimeInMillis();
+ }
+
+ /**
+ * 获得当前月--结束日期
+ *
+ * @return
+ */
+ public static Long getCurrentMonthLastDay(Long valueTime){
+ if (ObjectUtils.isEmpty(valueTime)) {
+ throw new RuntimeException("获取不到有效的结束时间:" + valueTime);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(System.currentTimeMillis());
+ calendar.add(Calendar.MONTH,1);
+ calendar.set(Calendar.DAY_OF_MONTH, 0);
+ //将时、分、秒、毫秒 清零
+ calendar.set(Calendar.HOUR_OF_DAY, 23);
+ calendar.set(Calendar.MINUTE, 59);
+ calendar.set(Calendar.SECOND, 59);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ return calendar.getTimeInMillis();
+ }
+
+
+ // 日期转字符串格式
+ public static String timeStamp2Date(String seconds, String format) {
+ if (StringUtils.isEmpty(seconds) || StringUtils.isEmpty(format)) {
+
+ }
+ if (format == null || format.isEmpty()) {
+ format = "yyyy-MM-dd HH:mm:ss";
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ return sdf.format(new Date(Long.valueOf(seconds)));
+ }
+
+ /**
+ * 获取给定时间 当天0点的时间戳
+ *
+ * @param time
+ * @return
+ */
+ public static Long getDayStartTime(Long time) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(new Date(time));
+
+ //将时、分、秒、毫秒 清零
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ return calendar.getTime().getTime();
+ }
+
+ /**
+ * 获取给定时间 当天24点的时间戳
+ *
+ * @param time
+ * @return
+ */
+ public static Long getDayEndTime(Long time) {
+ Long startTime = getDayStartTime(time);
+ Long oneDayTimeMillis = 60000 * 60 * 24L;
+ return startTime + oneDayTimeMillis;
+ }
+
+
+
+ /**
+ * 获取当前日期是星期几
+ *
+ * @param dt
+ * @return 当前日期是星期几
+ */
+ public static String getWeekOfDate(Date dt) {
+ String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dt);
+ int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+ if (w < 0)
+ w = 0;
+ return weekDays[w];
+ }
+
+ /**
+ * 指定某个月份返回其月份所有的天数
+ * @param valueMonth
+ */
+ public static List getDayByValueMonth(Long valueMonth) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(valueMonth);
+
+ // 对应月份
+ Integer month = calendar.get(Calendar.MONTH) + 1;
+ // 对应年份
+ Integer year = calendar.get(Calendar.YEAR);
+ // 获取当前月份格式化
+ Long formatMonth = getCurrentMonthFirstDay(valueMonth);
+ // 保存的数据
+ List currentDayList = new ArrayList<>();
+ currentDayList.add(formatMonth);
+ // 对应天数
+ Integer valueDay = 0;
+ switch (month) {
+ case 1: case 3: case 5: case 7: case 8: case 10: case 12:
+ valueDay = 31;
+ break;
+ case 4: case 6: case 9: case 11:
+ valueDay = 30;
+ break;
+ case 2:
+ valueDay = (year % 400) == 0 || ((year%4)==0)&&((year%100)!=0) ? 29 : 28;
+ break;
+ }
+ for (int i = 1; i<= valueDay - 1; i++) {
+ formatMonth += 86400000;
+ currentDayList.add(formatMonth);
+ }
+ return currentDayList;
+ }
+
+
+ public static void main(String[] args) {
+ System.out.println(getDayByValueMonth(System.currentTimeMillis()));
+ }
+
+
+}
diff --git a/src/main/java/com/cloud/commons/utils/JwtUtils.java b/src/main/java/com/cloud/commons/utils/JwtUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..140e2c8293e5259fe9df03b19c007a2f30c1c38b
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/JwtUtils.java
@@ -0,0 +1,46 @@
+package com.cloud.commons.utils;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.algorithms.Algorithm;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 基于token的认证信息
+ */
+@Component
+public class JwtUtils {
+ private static String SECRRT;
+
+ private static final Logger LOG = LoggerFactory.getLogger(JwtUtils.class);
+ /**
+ * 密匙,在有static的情况下通过注解拿不到SECRRT的数据,则只能通过set方法进行获取
+ */
+
+ @Value("${token.secret}")
+ public void setSECRRT(String secrrt){
+ SECRRT = secrrt;
+ }
+
+
+ public static String getToken() {
+ //失效时间 2小时后失效
+ final Long EXPIRES = System.currentTimeMillis() + 7200000;
+ String token="";
+ token= JWT.create()
+ //自定义字段
+// .withClaim("username",user.getUsername()).withClaim("userId",user.getId()).withClaim("password",user.getPassword()).withClaim("EXPIRES",EXPIRES)
+ .withExpiresAt(new Date(EXPIRES))
+ .sign(Algorithm.HMAC256(SECRRT));
+// LOG.info("获取到的token值是:" + token + "过期时间是:" + EXPIRES);
+ return token;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(System.currentTimeMillis() + 7200);
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/http/HttpUtil.java b/src/main/java/com/cloud/commons/utils/http/HttpUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2f6656c116f5d51116ba198ccde7d211504f90f
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/http/HttpUtil.java
@@ -0,0 +1,100 @@
+package com.cloud.commons.utils.http;
+
+import com.alibaba.fastjson.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Http 请求工具类
+ * created on 2019-01-03 21:21:43
+ *
+ * @author liori
+ * @since springboot-mybatis 0.0.1
+ */
+public class HttpUtil {
+
+ private final static Logger LOG = LoggerFactory.getLogger(HttpUtil.class);
+
+ /**
+ * 向指定URL发送GET方法的请求
+ *
+ * @param url
+ * @return
+ */
+ public static String doGet(String url) throws Exception {
+ URLConnection connection = getUrlConnection(url);
+ try {
+ // 建立实际的连接
+ connection.connect();
+ return getRequestResult(connection);
+ } catch (IOException e) {
+ LOG.error("doGet 请求异常:\n" + e);
+ throw new Exception("doGet 请求异常:\n" + e);
+ }
+ }
+
+ /**
+ * 向指定 URL 发送POST方法的请求
+ *
+ * @param url
+ * @param paramsJson
+ * @return
+ */
+ public static String doPost(String url, JSONObject paramsJson) throws Exception {
+ URLConnection connection = getUrlConnection(url);
+ // 发送POST请求必须设置如下两行
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ // 获取URLConnection对象对应的输出流
+ try (PrintWriter printWriter = new PrintWriter(connection.getOutputStream());) {
+ // 发送请求参数
+ printWriter.print(paramsJson.toString());
+ // flush 输出流的缓冲
+ printWriter.flush();
+ return getRequestResult(connection);
+ } catch (IOException e) {
+ LOG.error("doPost 请求异常:\n" + e);
+ throw new Exception("doPost 请求异常");
+ }
+ }
+
+ private static URLConnection getUrlConnection(String urlWithParams) throws Exception {
+ try {
+ URL realUrl = new URL(urlWithParams);
+ // 打开和URL之间的连接
+ URLConnection connection = realUrl.openConnection();
+ // 设置通用的请求属性
+ connection.setRequestProperty("accept", "*/*");
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+ return connection;
+ } catch (IOException e) {
+ LOG.error("打开URL连接时出现异常:\n" + e);
+ throw new Exception("打开URL连接时出现异常");
+ }
+ }
+
+ private static String getRequestResult(URLConnection connection) throws Exception {
+ // 定义 BufferedReader 输入流来读取URL的响应
+ try (InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream(), "UTF-8");
+ BufferedReader bufferedReader = new BufferedReader(inputStreamReader);) {
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
+ }
+ return result.toString();
+ } catch (IOException e) {
+ LOG.error("读取URL的响应时出现异常:\n" + e);
+ throw new Exception("读取URL的响应时出现异常:\n" + e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/commons/utils/message/MessageCode.java b/src/main/java/com/cloud/commons/utils/message/MessageCode.java
new file mode 100644
index 0000000000000000000000000000000000000000..7379835f7c130434696e3669b68e059943038cec
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/message/MessageCode.java
@@ -0,0 +1,14 @@
+package com.cloud.commons.utils.message;
+
+public class MessageCode {
+
+ /**
+ * 操作成功
+ */
+ public static final int SUCCESS_CODE_200 = 200;
+
+ /**
+ * 操作失败
+ */
+ public static final int ERROR_CODE_500 = 500;
+}
diff --git a/src/main/java/com/cloud/commons/utils/message/MessageDescription.java b/src/main/java/com/cloud/commons/utils/message/MessageDescription.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8b297820cf74d334d6fc164b3ed319fe4482f5c
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/message/MessageDescription.java
@@ -0,0 +1,80 @@
+
+package com.cloud.commons.utils.message;
+
+public class MessageDescription {
+
+ /**
+ * 操作成功
+ */
+ public static final String OPERATION_SUCCESS = "操作成功";
+
+ /**
+ * 操作失败
+ */
+ public static final String OPERATION_FAILURE = "操作失败";
+
+ /**
+ * 数据插入操作成功
+ */
+ public static final String OPERATION_INSERT_SUCCESS = "数据插入操作成功";
+
+ /**
+ * 数据插入操作失败
+ */
+ public static final String OPERATION_INSERT_FAILURE = "数据插入操作失败";
+
+ /**
+ * 数据删除操作成功
+ */
+ public static final String OPERATION_DELETE_SUCCESS = "数据删除操作成功";
+
+ /**
+ * 数据删除操作失败
+ */
+ public static final String OPERATION_DELETE_FAILURE = "数据删除操作失败";
+
+ /**
+ * 数据查询操作成功
+ */
+ public static final String OPERATION_QUERY_SUCCESS = "数据查询操作成功";
+
+ /**
+ * 数据查询操作失败
+ */
+ public static final String OPERATION_QUERY_FAILURE = "数据查询操作失败";
+
+ /**
+ * 数据更新操作成功
+ */
+ public static final String OPERATION_UPDATE_SUCCESS = "数据更新操作成功";
+
+ /**
+ * 数据更新操作失败
+ */
+ public static final String OPERATION_UPDATE_FAILURE = "数据更新操作失败";
+
+ /**
+ * 登陆成功
+ */
+ public static final String LOGIN_SUCCESS = "用户登陆成功";
+
+ /**
+ * 登陆失败
+ */
+ public static final String LOGIN_FAILURE = "用户登陆失败";
+
+ /**
+ * 登陆密码错误
+ */
+ public static final String LOGIN_WRONG_PASSWORD = "用户密码错误";
+
+ /**
+ * 登陆密码错误
+ */
+ public static final String LOGIN_USERNAME_EXIST = "用户名已存在";
+
+ /**
+ * 登陆密码错误
+ */
+ public static final String LOGIN_USERNAME_NOT_EXIST = "用户名不存在";
+}
diff --git a/src/main/java/com/cloud/commons/utils/message/Result.java b/src/main/java/com/cloud/commons/utils/message/Result.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b391ef6592f0b790ee4115c368ea27fabd6402e
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/message/Result.java
@@ -0,0 +1,41 @@
+package com.cloud.commons.utils.message;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "返回类")
+public class Result {
+
+ @ApiModelProperty(value = "状态码")
+ private int code;//状态码
+
+ @ApiModelProperty(value = "错误信息")
+ private String msg;//信息
+
+ @ApiModelProperty(value = "返回数据")
+ private T data;//数据
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/message/ResultUtil.java b/src/main/java/com/cloud/commons/utils/message/ResultUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..969d00535a88972820fbcf104a30cc51f139b1d8
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/message/ResultUtil.java
@@ -0,0 +1,22 @@
+package com.cloud.commons.utils.message;
+
+public class ResultUtil {
+
+
+ //当正确时返回的值
+ public static Result success(Integer code,String msg, Object data){
+ Result result = new Result();
+ result.setCode(code);
+ result.setMsg(msg);
+ result.setData(data);
+ return result;
+ }
+
+ //当错误时返回的值
+ public static Result> error(int code, String msg){
+ Result result = new Result();
+ result.setCode(code);
+ result.setMsg(msg);
+ return result;
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/weather/WeatherUtil.java b/src/main/java/com/cloud/commons/utils/weather/WeatherUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9b4aa620b995685a694e435fe465788c03bd2d8
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/weather/WeatherUtil.java
@@ -0,0 +1,44 @@
+package com.cloud.commons.utils.weather;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.cloud.commons.utils.wechat.HttpUtil;
+import com.mysql.cj.xdevapi.JsonArray;
+import org.apache.http.client.methods.HttpGet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WeatherUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(WeatherUtil.class);
+
+ private static String WEATHER_KEY = "a6f1b37a9c6c40fdb762df3fd50c4079";
+// @Value("${weather.key}")
+// private void setWeatherKey(String key) {
+// WEATHER_KEY = key;
+// }
+ /**
+ * {weather-type} 代表不同的天气数据类型,必选,请使用以下值替代:now:实况天气、 forecast:3-10天预报、hourly:逐小时预报、lifestyle:生活指数
+ * {parameters} 代表请求参数,包括必选和可选参数。所有请求参数均使用 &进行分隔,参数值存在中文或特殊字符的情况,需要对参数进行 url encode
+ * location 1. 城市ID:城市列表
+ * 2. 经纬度格式:经度,纬度(经度在前纬度在后,英文,分隔,十进制格式,北纬东经为正,南纬西经为负
+ * 3. 城市名称,支持中英文和汉语拼音
+ * 4. 城市名称,上级城市 或 省 或 国家,英文,分隔,此方式可以在重名的情况下只获取想要的地区的天气数据,例如 西安,陕西
+ * 5. IP
+ * 6. 根据请求自动判断,根据用户的请求获取IP,通过 IP 定位并获取城市数据
+ * key
+ */
+ private final static String heweather_url = "https://free-api.heweather.net/s6/weather/{weather-type}?{parameters}";
+
+
+ public static JSONObject getHeweatherResult(String weatherType,String city){
+ String heweatherUrl = heweather_url.replaceAll("\\{weather-type\\}",weatherType).replaceAll("\\{parameters\\}","location="+ city + "&key=" + WEATHER_KEY);
+ JSONObject jsonObject = HttpUtil.httpRequest(heweatherUrl,"GET",null);
+ JSONArray jsonValues = jsonObject.getJSONArray("HeWeather6");
+ JSONObject jsonObject1 = jsonValues.getJSONObject(0);
+
+ return jsonObject1;
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/wechat/HttpUtil.java b/src/main/java/com/cloud/commons/utils/wechat/HttpUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..8019bb0aff26895299c1c8da951974d6e851621e
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/wechat/HttpUtil.java
@@ -0,0 +1,180 @@
+package com.cloud.commons.utils.wechat;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import java.io.*;
+import java.net.ConnectException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.util.Map;
+import java.util.Set;
+
+public class HttpUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(HttpUtil.class);
+
+ public static String doPost(String url, Map params, String charset) {
+ StringBuffer response = new StringBuffer();
+ HttpClient client = new HttpClient();
+ PostMethod method = new PostMethod(url);
+ // 设置Http Post数据
+ method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
+ if (params != null) {
+ Set keySet = params.keySet();
+ NameValuePair[] param = new NameValuePair[keySet.size()];
+ int i = 0;
+ for (String key : keySet) {
+ param[i] = new NameValuePair(key, params.get(key));
+ i++;
+ }
+ method.setRequestBody(param);
+ }
+ InputStream responseBodyStream = null;
+ InputStreamReader streamReader = null;
+ BufferedReader reader = null;
+ try {
+ client.executeMethod(method);
+ if (method.getStatusCode() == HttpStatus.SC_OK) {
+ responseBodyStream = method.getResponseBodyAsStream();
+ streamReader = new InputStreamReader(responseBodyStream, charset);
+ reader = new BufferedReader(streamReader);
+ String line;
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ }
+ } catch (IOException e) {
+ LOG.error("执行HTTP Post请求" + url + "时,发生异常!", e);
+ } finally {
+ try {
+ responseBodyStream.close();
+ streamReader.close();
+ reader.close();
+ } catch (IOException e) {
+ LOG.error("执行HTTP Post请求" + url + "时,发生异常,关闭流异常!", e);
+ }
+ method.releaseConnection();
+ }
+ return response.toString();
+ }
+
+ /**
+ * 发起https请求并获取结果
+ *
+ * @param requestUrl
+ * 请求地址
+ * @param requestMethod
+ * 请求方式(GET、POST)
+ * @param outputStr
+ * 提交的数据
+ * @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值)
+ */
+ public static JSONObject httpRequest(String requestUrl,
+ String requestMethod, String outputStr) {
+ JSONObject jsonObject = null;
+ StringBuffer buffer = new StringBuffer();
+ try {
+ // 创建SSLContext对象,并使用我们指定的信任管理器初始化
+ TrustManager[] tm = { new MyX509TrustManager() };
+ SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
+ sslContext.init(null, tm, new java.security.SecureRandom());
+ // 从上述SSLContext对象中得到SSLSocketFactory对象
+ SSLSocketFactory ssf = sslContext.getSocketFactory();
+
+ URL url = new URL(requestUrl);
+ HttpsURLConnection httpUrlConn = (HttpsURLConnection) url
+ .openConnection();
+ httpUrlConn.setSSLSocketFactory(ssf);
+
+ httpUrlConn.setDoOutput(true);
+ httpUrlConn.setDoInput(true);
+ httpUrlConn.setUseCaches(false);
+ // 设置请求方式(GET/POST)
+ httpUrlConn.setRequestMethod(requestMethod);
+
+ if ("GET".equalsIgnoreCase(requestMethod))
+ httpUrlConn.connect();
+
+ // 当有数据需要提交时
+ if (null != outputStr) {
+ OutputStream outputStream = httpUrlConn.getOutputStream();
+ // 注意编码格式,防止中文乱码
+ outputStream.write(outputStr.getBytes("UTF-8"));
+ outputStream.close();
+ }
+
+ // 将返回的输入流转换成字符串
+ InputStream inputStream = httpUrlConn.getInputStream();
+ InputStreamReader inputStreamReader = new InputStreamReader(
+ inputStream, "utf-8");
+ BufferedReader bufferedReader = new BufferedReader(
+ inputStreamReader);
+
+ String str = null;
+ while ((str = bufferedReader.readLine()) != null) {
+ buffer.append(str);
+ }
+ bufferedReader.close();
+ inputStreamReader.close();
+ // 释放资源
+ inputStream.close();
+ inputStream = null;
+ httpUrlConn.disconnect();
+ jsonObject = JSONObject.parseObject(buffer.toString());
+ } catch (ConnectException ce) {
+ System.out.println("Weixin server connection timed out.");
+ } catch (Exception e) {
+ System.out.println("https request error:{}==> "+e.getMessage());
+ }
+ return jsonObject;
+ }
+
+ public static String sendHttpPost(String url, Object object) throws Exception {
+ CloseableHttpResponse response = null;
+ HttpEntity entity = null;
+ String responseContent = null;
+ try (CloseableHttpClient httpClient = HttpClients.createDefault();) {
+ HttpPost httpPost = new HttpPost(url);
+ StringEntity s = new StringEntity(JSON.toJSONString(object), Charset.forName("UTF-8"));
+ s.setContentEncoding("UTF-8");
+ // 发送json数据需要设置contentType
+ // s.setContentType("application/json");
+ httpPost.setEntity(s);
+ // 执行请求
+ response = httpClient.execute(httpPost);
+ entity = response.getEntity();
+ responseContent = EntityUtils.toString(entity, "UTF-8");
+ } catch (IOException e) {
+ LOG.error("http post 连接异常",e);
+ throw new Exception("请求http出错:" + url + "\n" + e);
+ } finally {
+ try {
+ // 关闭连接,释放资源
+ if (response != null) {
+ response.close();
+ }
+ } catch (IOException e) {
+ LOG.error("http post 连接异常",e);
+ throw new Exception("关闭连接,释放资源时出错:" + url, e);
+ }
+ }
+ return responseContent;
+ }
+}
diff --git a/src/main/java/com/cloud/commons/utils/wechat/MyX509TrustManager.java b/src/main/java/com/cloud/commons/utils/wechat/MyX509TrustManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..10d3fcc51a61e7681d51c2ad9b05775e5475f266
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/wechat/MyX509TrustManager.java
@@ -0,0 +1,23 @@
+package com.cloud.commons.utils.wechat;
+
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class MyX509TrustManager implements X509TrustManager {
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
+
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cloud/commons/utils/wechat/WeixinUtil.java b/src/main/java/com/cloud/commons/utils/wechat/WeixinUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..5a061699f1fc47e728b67ad7dcfd94d7d9d3c294
--- /dev/null
+++ b/src/main/java/com/cloud/commons/utils/wechat/WeixinUtil.java
@@ -0,0 +1,201 @@
+package com.cloud.commons.utils.wechat;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONException;
+import com.alibaba.fastjson.JSONObject;
+import com.cloud.model.entity.accesstoken.AccessToken;
+import com.cloud.model.entity.wxmintemplateproject.WxMinTemplateProject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+
+@Component
+public class WeixinUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(WeixinUtil.class);
+
+ public final static String access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+
+
+ public static String APPID;
+ @Value("${wxMinProject.appId}")
+ public void setAppId(String APPID) {
+ this.APPID = APPID;
+ }
+
+ public static String APPSECRET;
+ @Value("${wxMinProject.appSecret}")
+ public void setAppsecret(String APPSECRET) {
+ this.APPSECRET = APPSECRET;
+ }
+
+
+
+ /**
+ * 获取token
+ * @return
+ */
+ public static AccessToken getAccessToken() {
+ AccessToken accessToken = null;
+ String requestUrl = access_token_url.replace("APPID", APPID).replace(
+ "APPSECRET", APPSECRET);
+
+
+ JSONObject jsonObject = HttpUtil.httpRequest(requestUrl, "GET", null);
+
+ // 如果请求成功
+ if (null != jsonObject) {
+ try {
+ accessToken = new AccessToken();
+ accessToken.setAccessToken(jsonObject.getString("access_token"));
+ accessToken.setExpiresIn(jsonObject.getInteger("expires_in"));
+ } catch (JSONException e) {
+ accessToken = null;
+ // 获取token失败
+ System.out.println(e.getMessage());
+
+ }
+ }
+ return accessToken;
+ }
+
+ /**
+ * 通过code获取到用户的openId
+ * @param code
+ * @return
+ */
+ public static String code2Session(String code) {
+ LOG.info("app_id:" + APPID + "app_secret:" + APPSECRET);
+ String code2SessionUrl = "https://api.weixin.qq.com/sns/jscode2session?appid="+ APPID +"&secret="+APPSECRET+"&js_code="+code+"&grant_type=authorization_code";
+
+ LOG.info("request url:" + code2SessionUrl);
+
+ JSONObject jsonObject = HttpUtil.httpRequest(code2SessionUrl,"GET",null);
+
+ LOG.info("request data:" + JSON.toJSONString(jsonObject));
+
+ String openId = "";
+
+ if (ObjectUtils.isEmpty(jsonObject)) {
+ throw new NullPointerException("获取openId失败");
+ }
+
+ // 可以获取到数据啦
+ try{
+ openId = jsonObject.getString("openid");
+ }catch (JSONException e) {
+ throw new NullPointerException("获取openId失败");
+ }
+ LOG.info("openId获取成功");
+ return openId;
+ }
+
+
+ /**
+ * 小程序推送模板消息
+ * @param accessToken
+ * @param params
+ * @return
+ */
+ public static String sendMiniProgramTemplate(String accessToken, JSONObject params) throws Exception {
+ String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
+ String result = HttpUtil.sendHttpPost(requestUrl, params);
+ return result;
+ }
+
+ /**
+ * 生成小程序推送模板消息所需传递的 json 数据
+ * @param wxMinTemplateProject
+ * @return
+ */
+ public static JSONObject setMiniProgramTemplateData(WxMinTemplateProject wxMinTemplateProject) {
+ JSONObject resultJson = new JSONObject();
+ resultJson.put("touser", wxMinTemplateProject.getOpenId());
+ resultJson.put("template_id", wxMinTemplateProject.getTemplateId());
+ if (!StringUtils.isEmpty(wxMinTemplateProject.getPage())) {
+ resultJson.put("page", wxMinTemplateProject.getPage());
+ }
+
+ List keywordValues = wxMinTemplateProject.getKeywordData();
+ JSONObject templateMessageData = new JSONObject();
+ String templateId = wxMinTemplateProject.getTemplateId();
+ if (templateId.equals("nlD1JNUEtWlHjUiqcNFOYJQBG-akvOSbST0b0aWllOs")) {
+ // 记账成功提醒
+ for (int i = 0; i< keywordValues.size();i++) {
+ JSONObject valueObject = new JSONObject();
+ valueObject.put("value",keywordValues.get(i));
+ String keyword = "";
+ switch (i) {
+ case 0:
+ keyword = "time" + (i + 1);
+ break;
+ case 1:
+ keyword = "phrase" + (i + 1);
+ break;
+ case 2:
+ keyword = "amount" + (i + 1);
+ break;
+ case 3:
+ keyword = "name" + (i + 1);
+ break;
+ case 4:
+ keyword = "thing" + (i + 1);
+ break;
+ }
+ templateMessageData.put(keyword,valueObject);
+ }
+ } else if (templateId.equals("9idG4F8CNOaiGOo5EYwqB4wxVx8QXtoSg1HjNMnlM4M")){
+ // 记账预算提醒
+ for (int i = 0; i< keywordValues.size();i++) {
+ JSONObject valueObject = new JSONObject();
+ valueObject.put("value",keywordValues.get(i));
+ String keyword = "";
+ switch (i) {
+ case 0:
+ keyword = "time" + (i + 1);
+ break;
+ case 1:
+ keyword = "phrase" + (i + 1);
+ break;
+ case 2:
+ keyword = "amount" + (i + 1);
+ break;
+ case 3:
+ keyword = "thing" + (i + 1);
+ break;
+ }
+ templateMessageData.put(keyword,valueObject);
+ }
+ } else if (templateId.equals("e5WNxg6ppcab2LvQTHVPutAlb6BJYAzheIkauWkWS1Q")) {
+ // 版本更新通知
+ for (int i = 0; i< keywordValues.size();i++) {
+ JSONObject valueObject = new JSONObject();
+ valueObject.put("value",keywordValues.get(i));
+ String keyword = "";
+ switch (i) {
+ case 0:
+ keyword = "character_string" + (i + 1);
+ break;
+ case 1:
+ keyword = "thing" + (i + 1);
+ break;
+ }
+ templateMessageData.put(keyword,valueObject);
+ }
+ } else {
+ throw new RuntimeException("匹配不到有效的订阅id");
+ }
+
+ resultJson.put("data", templateMessageData);
+
+ return resultJson;
+ }
+
+
+}
diff --git a/src/main/java/com/cloud/config/MyWebMvcConfigurerAdapter.java b/src/main/java/com/cloud/config/MyWebMvcConfigurerAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..a134d69b5495d3981be90c13f2fb1241768ec78a
--- /dev/null
+++ b/src/main/java/com/cloud/config/MyWebMvcConfigurerAdapter.java
@@ -0,0 +1,29 @@
+package com.cloud.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
+
+ //图片存放根路径
+// @Value("${file.staticAccessPath}")
+// private String staticAccessPath;
+// @Value("${file.rootPath}")
+// private String rootPath;
+
+ //图片存放根目录下的子目录
+// @Value("${file.sonPath}")
+// private String sonPath;
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry){
+// String filePath = "file:" + rootPath + sonPath;
+ //指向外部目录
+// registry.addResourceHandler(staticAccessPath).addResourceLocations(filePath);
+ registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
+ registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
+ super.addResourceHandlers(registry);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cloud/config/WebMvcConfig.java b/src/main/java/com/cloud/config/WebMvcConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..d07d5929e5d8ff81154e76e455da68ffcc2ec0bd
--- /dev/null
+++ b/src/main/java/com/cloud/config/WebMvcConfig.java
@@ -0,0 +1,48 @@
+package com.cloud.config;
+
+
+
+import com.cloud.config.toekn.AuthenticationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * 解决跨域问题
+ */
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+ /**
+ * addPathPatterns 用于添加拦截规则
+ * excludePathPatterns 用户排除拦截
+ * @param registry
+ */
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ registry.addInterceptor(authenticationInterceptor())
+ .addPathPatterns("/api/**")
+ .excludePathPatterns("/**");
+ }
+ @Bean
+ public AuthenticationInterceptor authenticationInterceptor() {
+ return new AuthenticationInterceptor();
+ }
+
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ System.out.println("我是MyWebConfig跨域");
+ //设置允许跨域的路径
+ registry.addMapping("/**")
+ //设置允许跨域请求的域名
+ .allowedOrigins("*")
+ //是否允许证书 不再默认开启
+ .allowCredentials(true)
+ //设置允许的方法
+ .allowedMethods("*")
+ //跨域允许时间
+ .maxAge(3600);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cloud/config/swagger/StepExecutorConfig.java b/src/main/java/com/cloud/config/swagger/StepExecutorConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..5bd927b44b56ecbf89e6b36afd5041cb87e5cb12
--- /dev/null
+++ b/src/main/java/com/cloud/config/swagger/StepExecutorConfig.java
@@ -0,0 +1,62 @@
+package com.cloud.config.swagger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * 项目启动时自动打开http://localhost:9036/swagger-ui.html
+ */
+@Component
+public class StepExecutorConfig implements ApplicationRunner {
+ private static final Logger LOG = LoggerFactory.getLogger(StepExecutorConfig.class);
+
+ @Value("${spring.web.loginurl}")
+ private String loginUrl;
+
+ @Value("${spring.web.googleexcute}")
+ private String googleExcutePath;
+
+ @Value("${spring.web.isopenurl}")
+ private boolean isOpen;
+ @Override
+ public void run(ApplicationArguments args){
+ //先判断当前环境
+ if (!exitisVersion()){
+ //启动swagger-ui
+ application();
+ }
+ }
+
+ private Boolean exitisVersion() {
+ String osName = System.getProperties().getProperty("os.name");
+ if(osName.equals("Linux")) {
+ LOG.info("running in Linux");
+ return true;
+ }
+ else{
+ LOG.info("don't running in Linux");
+ return false;
+ }
+ }
+
+ private void application() {
+
+ if (isOpen){
+ String cmd = googleExcutePath +" "+ loginUrl;
+ LOG.info("浏览地址:" + cmd);
+ Runtime run = Runtime.getRuntime();
+ try{
+ run.exec(cmd);
+ LOG.info("启动浏览器打开项目成功");
+ }catch (Exception e){
+ e.printStackTrace();
+ LOG.error(e.getMessage());
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/cloud/config/swagger/SwaggerConfig.java b/src/main/java/com/cloud/config/swagger/SwaggerConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..c6dd66570ae92705c2f42b7f883514ad1bc49723
--- /dev/null
+++ b/src/main/java/com/cloud/config/swagger/SwaggerConfig.java
@@ -0,0 +1,60 @@
+package com.cloud.config.swagger;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description : swagger配置配置
+ * @Author : Mars
+ * @Date : 2017年9月6日
+ */
+@WebAppConfiguration
+@EnableSwagger2
+@EnableWebMvc
+@Configuration
+//@ComponentScan(basePackageClasses = {ApisController.class }) //Instructs spring where to scan for API controllers
+public class SwaggerConfig {
+
+ /**
+ * Every Docket bean is picked up by the swagger-mvc framework - allowing for multiple
+ * swagger groups i.e. same code base multiple swagger resource listings.
+ */
+ @Bean
+ public Docket customDocket(){
+ ParameterBuilder ticketPar = new ParameterBuilder();
+ List pars = new ArrayList();
+ ticketPar.name("Authorization").description("令牌")
+ .modelRef(new ModelRef("string")).parameterType("header")
+ .required(false).build(); //header中的ticket参数非必填,传空也可以
+ pars.add(ticketPar.build()); //根据每个方法名也知道当前方法在设置什么参数
+
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.any())
+ .build()
+ .globalOperationParameters(pars);
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("创意云后台接口")
+ .description("前后端联调swagger api 文档")
+ .version("1.1.0")
+ .build();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cloud/config/toekn/AuthenticationInterceptor.java b/src/main/java/com/cloud/config/toekn/AuthenticationInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c6e000ffa2123e630f52f5d758316ba834fe38e
--- /dev/null
+++ b/src/main/java/com/cloud/config/toekn/AuthenticationInterceptor.java
@@ -0,0 +1,96 @@
+package com.cloud.config.toekn;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.ObjectUtils;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 拦截器,拦截所有请求信息,验证token信息
+ */
+public class AuthenticationInterceptor implements HandlerInterceptor {
+
+ private final static Logger LOG = LoggerFactory.getLogger(AuthenticationInterceptor.class);
+
+
+ @Value("${token.secret}")
+ private String SECRET;
+
+ @Override
+ public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
+// LOG.info("-----被拦截到了,开始校验token信息------");
+ String method = httpServletRequest.getMethod();
+ // 如果拦截到的是OPTIONS请求的话,则放行
+ if (method.equals("OPTIONS")) {
+ return true;
+ }
+ String token = httpServletRequest.getHeader("Authorization");// 从 http 请求头中取出 token
+ if (ObjectUtils.isEmpty(token)){
+ throw new Exception("token不合法");
+// throw new Exception("token不合法!!!" + token);
+ }
+ // 如果不是映射到方法直接通过
+// if(!(object instanceof HandlerMethod)){
+// return true;
+// }
+// HandlerMethod handlerMethod=(HandlerMethod)object;
+// Method method=handlerMethod.getMethod();
+ //检查是否有passtoken注释,有则跳过认证
+// if (method.isAnnotationPresent(PassToken.class)) {
+// PassToken passToken = method.getAnnotation(PassToken.class);
+// if (passToken.required()) {
+// return true;
+// }
+// }
+// //检查有没有需要用户权限的注解
+// if (method.isAnnotationPresent(UserLoginToken.class)) {
+// UserLoginToken userLoginToken = method.getAnnotation(UserLoginToken.class);
+// if (userLoginToken.required()) {
+// // 执行认证
+// if (token == null) {
+// throw new RuntimeException("无token,请重新登录");
+// }
+// // 获取 token 中的 user id
+// String userId;
+// try {
+// userId = JWT.decode(token).getAudience().get(0);
+// } catch (JWTDecodeException j) {
+// throw new RuntimeException("401");
+// }
+// User user = userService.findUserById(userId);
+// if (user == null) {
+// throw new RuntimeException("用户不存在,请重新登录");
+// }
+ // 验证 token
+ try {
+ JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(SECRET)).build();
+ jwtVerifier.verify(token);
+// LOG.info("校验通过!!!!!");
+ } catch (JWTVerificationException e) {
+ throw new RuntimeException("401,请联系管理员");
+ }
+ return true;
+ }
+
+ @Override
+ public void postHandle(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse,
+ Object o, ModelAndView modelAndView) throws Exception {
+
+ }
+
+ @Override
+ public void afterCompletion(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse,
+ Object o, Exception e) throws Exception {
+ }
+}
diff --git a/src/main/java/com/cloud/controller/assets/AssetsController.java b/src/main/java/com/cloud/controller/assets/AssetsController.java
new file mode 100644
index 0000000000000000000000000000000000000000..55af4d1d406aef9c718e9700096504d49b3f2fb8
--- /dev/null
+++ b/src/main/java/com/cloud/controller/assets/AssetsController.java
@@ -0,0 +1,148 @@
+package com.cloud.controller.assets;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.assets.AssetsView;
+import com.cloud.service.assets.AssetsService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * AssetsController
+ *
+ * Assets的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-15 17:21:44.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]用户资产统计表接口",tags = "[Cloud Source]用户资产统计表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class AssetsController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AssetsController.class);
+
+ /** The service. */
+ @Autowired
+ private AssetsService assetsService;
+
+ @ApiOperation(value = "[Cloud Source]创建用户资产统计表", notes = "创建一个用户资产统计表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetss", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createAssets(
+ @ApiParam(value = "用户资产统计表", required = true) @RequestBody AssetsView assetsView) {
+ try {
+ // 保存实体
+ AssetsView assetsView1 = assetsService.saveEntity(assetsView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_QUERY_FAILURE, assetsView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500,t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户资产统计表", notes = "通过id删除用户资产统计表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetss/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteAssets(
+ @ApiParam(value = "用户资产统计表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ assetsService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户资产统计表", notes = "批量删除用户资产统计表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetss", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteAssetss(
+ @ApiParam(value = "用户资产统计表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ assetsService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新用户资产统计表", notes = "更新用户资产统计表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/assetss/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateAssetss(
+ @ApiParam(value = "用户资产统计表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "用户资产统计表信息", required = true) @RequestBody AssetsView assetsView) {
+ try {
+ assetsView.setId(id);
+ assetsService.updateEntity(assetsView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,assetsView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个用户资产统计表", notes = "通过id获取用户资产统计表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetss/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getAssets(
+ @ApiParam(value = "用户资产统计表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final AssetsView assetsView = assetsService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, assetsView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+
+ @ApiOperation(value = "[Cloud Source]获取单个用户资产统计表", notes = "通过userId获取用户资产统计表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetss/userid/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getAssetsByUserId(
+ @ApiParam(value = "用户id", required = true) @PathVariable(value = "userId") Long userId) {
+ try {
+ final AssetsView assetsView = assetsService.getAssetsViewByUserId(userId);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, assetsView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/assetsdetail/AssetsDetailController.java b/src/main/java/com/cloud/controller/assetsdetail/AssetsDetailController.java
new file mode 100644
index 0000000000000000000000000000000000000000..d26988961aca4653e874e86042f454dc748779a8
--- /dev/null
+++ b/src/main/java/com/cloud/controller/assetsdetail/AssetsDetailController.java
@@ -0,0 +1,142 @@
+package com.cloud.controller.assetsdetail;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.assetsdetail.AssetsDetailView;
+import com.cloud.service.assetsdetail.AssetsDetailService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * AssetsDetailController
+ *
+ * AssetsDetail的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-15 17:22:19.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]用户资产统计明细表接口",tags = "[Cloud Source]用户资产统计明细表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class AssetsDetailController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AssetsDetailController.class);
+
+ /** The service. */
+ @Autowired
+ private AssetsDetailService assetsDetailService;
+
+ @ApiOperation(value = "[Cloud Source]创建用户资产统计明细表", notes = "创建一个用户资产统计明细表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetsdetails", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createAssetsDetail(
+ @ApiParam(value = "用户资产统计明细表", required = true) @RequestBody AssetsDetailView assetsDetailView) {
+ try {
+ // 保存实体
+ AssetsDetailView assetsDetailView1 = assetsDetailService.saveEntity(assetsDetailView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, assetsDetailView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户资产统计明细表", notes = "通过id删除用户资产统计明细表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetsdetails/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteAssetsDetail(
+ @ApiParam(value = "用户资产统计明细表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ assetsDetailService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户资产统计明细表", notes = "批量删除用户资产统计明细表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetsdetails", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteAssetsDetails(
+ @ApiParam(value = "用户资产统计明细表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ assetsDetailService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新用户资产统计明细表", notes = "更新用户资产统计明细表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/assetsdetails/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateAssetsDetails(
+ @ApiParam(value = "用户资产统计明细表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "用户资产统计明细表信息", required = true) @RequestBody AssetsDetailView assetsDetailView) {
+ try {
+ assetsDetailView.setId(id);
+ assetsDetailService.updateEntity(assetsDetailView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,assetsDetailView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个用户资产统计明细表", notes = "通过用户id获取用户资产统计明细表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetsdetails/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getAssetsDetail(
+ @ApiParam(value = "用户id", required = true) @PathVariable(value = "userId") Long userId) {
+ try {
+ final AssetsDetailView assetsDetailView = assetsDetailService.getEntityByUserId(userId);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, assetsDetailView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+
+ @ApiOperation(value = "[Cloud Source]通过用户id和指定时间获取用户每天消费情况", notes = "通过用户id和指定时间获取用户每天消费情况")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/assetsdetails/{userId}/{valueTime}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getAssetsDetailByUserIdAndValueTime(
+ @ApiParam(value = "用户id", required = true) @PathVariable(value = "userId") Long userId,
+ @ApiParam(value = "指定时间", required = true) @PathVariable(value = "valueTime") Long valueTime) {
+ try {
+ final AssetsDetailView assetsDetailView = assetsDetailService.getAssetsDetailViewByValueMonthAndUserId(userId,valueTime);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, assetsDetailView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+}
diff --git a/src/main/java/com/cloud/controller/bookkeeping/BookkeepingController.java b/src/main/java/com/cloud/controller/bookkeeping/BookkeepingController.java
new file mode 100644
index 0000000000000000000000000000000000000000..05d6e3218238fb9576289885b45206dc7a925e95
--- /dev/null
+++ b/src/main/java/com/cloud/controller/bookkeeping/BookkeepingController.java
@@ -0,0 +1,147 @@
+package com.cloud.controller.bookkeeping;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.bookkeeping.BookkeepingView;
+import com.cloud.service.bookkeeping.BookkeepingService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * BookkeepingController
+ *
+ * Bookkeeping的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-15 17:24:19.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]记账表接口",tags = "[Cloud Source]记账表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class BookkeepingController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(BookkeepingController.class);
+
+ /** The service. */
+ @Autowired
+ private BookkeepingService bookkeepingService;
+
+ @ApiOperation(value = "[Cloud Source]创建记账表", notes = "创建一个记账表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/bookkeepings", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createBookkeeping(
+ @ApiParam(value = "记账表", required = true) @RequestBody BookkeepingView bookkeepingView) {
+ try {
+ // 保存实体
+ BookkeepingView bookkeepingView1 = bookkeepingService.saveBookkeepingView(bookkeepingView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, bookkeepingView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除记账表", notes = "通过id删除记账表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/bookkeepings/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteBookkeeping(
+ @ApiParam(value = "记账表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ bookkeepingService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除记账表", notes = "批量删除记账表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/bookkeepings", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteBookkeepings(
+ @ApiParam(value = "记账表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ bookkeepingService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新记账表", notes = "更新记账表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/bookkeepings/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateBookkeepings(
+ @ApiParam(value = "记账表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "记账表信息", required = true) @RequestBody BookkeepingView bookkeepingView) {
+ try {
+ bookkeepingView.setId(id);
+ bookkeepingService.updateEntity(bookkeepingView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,bookkeepingView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个记账表", notes = "通过id获取记账表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/bookkeepings/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getBookkeeping(
+ @ApiParam(value = "记账表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final BookkeepingView bookkeepingView = bookkeepingService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, bookkeepingView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "获取记账表信息并进行分页", notes = "获取记账表信息并进行分页")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error")})
+ @RequestMapping(value = "/v1/bookkeepings", method = RequestMethod.GET)
+ public Result> getEntity(@ApiParam(value = "用户id",required = true) @RequestParam(value = "userId",required = true) Long userId,
+ @ApiParam(value = "pageNumber", defaultValue = "0",required = false) @RequestParam(value = "pageNumber",defaultValue = "0",required = false) Integer pageNumber,
+ @ApiParam(value = "pageSize", defaultValue = "10",required = false) @RequestParam(value = "pageSize",defaultValue = "10",required = false) Integer pageSize) {
+ try {
+ Page bookkeepingView = bookkeepingService.getEntityPage(userId,pageNumber,pageSize);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, bookkeepingView);
+ } catch (Exception e) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, e.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/city/CityController.java b/src/main/java/com/cloud/controller/city/CityController.java
new file mode 100644
index 0000000000000000000000000000000000000000..79c87b8655e0aaad32f94e91e24abd226196b051
--- /dev/null
+++ b/src/main/java/com/cloud/controller/city/CityController.java
@@ -0,0 +1,131 @@
+package com.cloud.controller.city;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.city.CityView;
+import com.cloud.service.city.CityService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * CityController
+ *
+ * City的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-16 14:30:33.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]城市表接口",tags = "[Cloud Source]城市表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class CityController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(CityController.class);
+
+ /** The service. */
+ @Autowired
+ private CityService cityService;
+
+ @ApiOperation(value = "[Cloud Source]创建城市表", notes = "创建一个城市表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/citys", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createCity(
+ @ApiParam(value = "城市表", required = true) @RequestBody CityView cityView) {
+ try {
+ // 保存实体
+ CityView cityView1 = cityService.saveEntity(cityView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, cityView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除城市表", notes = "通过id删除城市表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/citys/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteCity(
+ @ApiParam(value = "城市表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ cityService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除城市表", notes = "批量删除城市表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/citys", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteCitys(
+ @ApiParam(value = "城市表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ cityService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新城市表", notes = "更新城市表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/citys/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateCitys(
+ @ApiParam(value = "城市表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "城市表信息", required = true) @RequestBody CityView cityView) {
+ try {
+ cityView.setId(id);
+ cityService.updateEntity(cityView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,cityView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个城市表", notes = "通过id获取城市表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/citys/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getCity(
+ @ApiParam(value = "城市表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final CityView cityView = cityService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, cityView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/cityweather/CityWeatherController.java b/src/main/java/com/cloud/controller/cityweather/CityWeatherController.java
new file mode 100644
index 0000000000000000000000000000000000000000..12290efadb602305ad2c16a1181a095448be007c
--- /dev/null
+++ b/src/main/java/com/cloud/controller/cityweather/CityWeatherController.java
@@ -0,0 +1,130 @@
+package com.cloud.controller.cityweather;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.cityweather.CityWeatherView;
+import com.cloud.service.cityweather.CityWeatherService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * CityWeatherController
+ *
+ * CityWeather的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-16 14:31:05.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]城市-天气信息表接口",tags = "[Cloud Source]城市-天气信息表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class CityWeatherController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(CityWeatherController.class);
+
+ /** The service. */
+ @Autowired
+ private CityWeatherService cityWeatherService;
+
+ @ApiOperation(value = "[Cloud Source]创建城市-天气信息表", notes = "创建一个城市-天气信息表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/cityweathers", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createCityWeather(
+ @ApiParam(value = "城市-天气信息表", required = true) @RequestBody CityWeatherView cityWeatherView) {
+ try {
+ // 保存实体
+ CityWeatherView cityWeatherView1 = cityWeatherService.saveEntity(cityWeatherView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, cityWeatherView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除城市-天气信息表", notes = "通过id删除城市-天气信息表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/cityweathers/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteCityWeather(
+ @ApiParam(value = "城市-天气信息表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ cityWeatherService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除城市-天气信息表", notes = "批量删除城市-天气信息表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/cityweathers", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteCityWeathers(
+ @ApiParam(value = "城市-天气信息表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ cityWeatherService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新城市-天气信息表", notes = "更新城市-天气信息表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/cityweathers/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateCityWeathers(
+ @ApiParam(value = "城市-天气信息表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "城市-天气信息表信息", required = true) @RequestBody CityWeatherView cityWeatherView) {
+ try {
+ cityWeatherView.setId(id);
+ cityWeatherService.updateEntity(cityWeatherView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,cityWeatherView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个城市-天气信息表", notes = "通过id获取城市-天气信息表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/cityweathers/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getCityWeather(
+ @ApiParam(value = "城市-天气信息表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final CityWeatherView cityWeatherView = cityWeatherService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, cityWeatherView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/consumetype/ConsumeTypeController.java b/src/main/java/com/cloud/controller/consumetype/ConsumeTypeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..9463b70d81430787367f5aab3549f81d2ba834c8
--- /dev/null
+++ b/src/main/java/com/cloud/controller/consumetype/ConsumeTypeController.java
@@ -0,0 +1,149 @@
+package com.cloud.controller.consumetype;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.consumetype.ConsumeTypeView;
+import com.cloud.service.consumetype.ConsumeTypeService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.util.List;
+
+/**
+ * ConsumeTypeController
+ *
+ * ConsumeType的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-15 17:23:42.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]消费类型表接口",tags = "[Cloud Source]消费类型表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class ConsumeTypeController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(ConsumeTypeController.class);
+
+ /** The service. */
+ @Autowired
+ private ConsumeTypeService consumeTypeService;
+
+ @ApiOperation(value = "[Cloud Source]创建消费类型表", notes = "创建一个消费类型表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/consumetypes", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createConsumeType(
+ @ApiParam(value = "消费类型表", required = true) @RequestBody ConsumeTypeView consumeTypeView) {
+ try {
+ // 保存实体
+ ConsumeTypeView consumeTypeView1 = consumeTypeService.saveEntity(consumeTypeView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, consumeTypeView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除消费类型表", notes = "通过id删除消费类型表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/consumetypes/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteConsumeType(
+ @ApiParam(value = "消费类型表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ consumeTypeService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除消费类型表", notes = "批量删除消费类型表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/consumetypes", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteConsumeTypes(
+ @ApiParam(value = "消费类型表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ consumeTypeService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新消费类型表", notes = "更新消费类型表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/consumetypes/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateConsumeTypes(
+ @ApiParam(value = "消费类型表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "消费类型表信息", required = true) @RequestBody ConsumeTypeView consumeTypeView) {
+ try {
+ consumeTypeView.setId(id);
+ consumeTypeService.updateEntity(consumeTypeView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,consumeTypeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个消费类型表", notes = "通过id获取消费类型表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/consumetypes/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getConsumeType(
+ @ApiParam(value = "消费类型表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final ConsumeTypeView consumeTypeView = consumeTypeService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, consumeTypeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个消费类型表", notes = "通过id获取消费类型表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/consumetypes/type", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getAllEntity(
+ @ApiParam(value = "消费类型", required = true) @RequestParam Integer type) {
+ try {
+ final List consumeTypeView = consumeTypeService.getAllEntityByType(type);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, consumeTypeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/uploadfile/UploadController.java b/src/main/java/com/cloud/controller/uploadfile/UploadController.java
new file mode 100644
index 0000000000000000000000000000000000000000..61cc73497a47381579eab22e9a2609556eb067e3
--- /dev/null
+++ b/src/main/java/com/cloud/controller/uploadfile/UploadController.java
@@ -0,0 +1,151 @@
+package com.cloud.controller.uploadfile;
+
+import com.cloud.commons.utils.DateUtils;
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import io.swagger.annotations.*;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+
+@RestController
+@RequestMapping(value = "/api")
+@Api(value = "[Cloud Source]上传图片接口", tags = "[Cloud Source]上传图片接口", description = "")
+public class UploadController {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UploadController.class);
+
+ //图片存放根路径
+ @Value("${file.rootPath}")
+ private String ROOT_PATH;
+ //图片存放根路径
+ @Value("${file.sonPath}")
+ private String SON_PATH;
+
+ @ApiOperation(value = "[Cloud Source]上传记账图片接口", notes = "[Cloud Source]上传记账图片接口")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error")})
+ @RequestMapping(value = "/v1/upload/{filePath}", method = RequestMethod.POST)
+ @ResponseBody
+ public Result> userUpload(@ApiParam(value = "filePath", required = true) @PathVariable("filePath") String filePath,
+ @ApiParam(value = "file", required = true) @RequestParam("file") MultipartFile file) {
+ try {
+ String path = this.getUploadFilePath(file,filePath);
+
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS,path);
+ }catch (Exception e){
+ return ResultUtil.error(MessageCode.ERROR_CODE_500,e.getMessage());
+ }
+
+ }
+
+ @ApiOperation(value = "[Cloud Source]上传记账记录图", notes = "[Cloud Source]上传记账记录图")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error")})
+ @RequestMapping(value = "/v1/upload/bookkeeping/{filePath}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.POST})
+ public Result> uploadProductCommentImage(@ApiParam(value = "filePath", required = true) @PathVariable("filePath") String filePath,
+ HttpServletRequest request, HttpServletResponse response) {
+ try {
+ String path = upload(request, filePath);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_INSERT_SUCCESS,path);
+ }catch (Exception e){
+ return ResultUtil.error(MessageCode.ERROR_CODE_500,e.getMessage());
+ }
+ }
+
+ public String getUploadFilePath(MultipartFile file,String filePathRequest){
+ //返回上传的文件是否为空,即没有选择任何文件,或者所选文件没有内容。
+ //防止上传空文件导致奔溃
+ if (file.isEmpty()) {
+ throw new NullPointerException("文件为空");
+ }
+ // 设置文件上传后的路径
+ String filePath = ROOT_PATH + SON_PATH + filePathRequest + "/";
+ // 获取文件名后缀名
+ String suffix = file.getOriginalFilename();
+ String prefix = suffix.substring(suffix.lastIndexOf(".")+1);
+ //为防止文件重名被覆盖,文件名取名为:当前日期 + 1-1000内随机数
+ Random random = new Random();
+ Integer randomFileName = random.nextInt(1000);
+ String fileName = DateUtils.timeStamp2Date(String.valueOf(System.currentTimeMillis() /100),"yyyyMMddHHmmss") + randomFileName +"." + prefix;
+ //创建文件路径
+ System.out.println("file:" + filePath + fileName);
+
+ File dest = new File(filePath + fileName);
+ // 解决中文问题,liunx下中文路径,图片显示问题
+ // fileName = UUID.randomUUID() + suffixName;
+ // 检测是否存在目录
+ if (!dest.getParentFile().exists()) {
+ //假如文件不存在即重新创建新的文件已防止异常发生
+ dest.getParentFile().mkdirs();
+ }
+ try {
+ //transferTo(dest)方法将上传文件写到服务器上指定的文件
+ file.transferTo(dest);
+ String filePathNew = SON_PATH + filePathRequest + "/" + fileName;
+ return filePathNew;
+ } catch (Exception e) {
+ return dest.toString();
+ }
+ }
+
+ /**
+ * 具体保存操作
+ *
+ * @param request
+ * @param type
+ * @return
+ */
+ private String upload(HttpServletRequest request, String type) {
+ MultipartHttpServletRequest mhs = (MultipartHttpServletRequest) request;
+ MultipartFile file = mhs.getFile("file");
+ ServletContext application = request.getSession().getServletContext();
+ LOG.info("pic url: " + application.getRealPath("/"));
+ String savePath = ROOT_PATH + SON_PATH;
+ String filePath = type + "/";
+ String newFileName = "";
+ try {
+ if (file != null && !file.isEmpty()) {
+
+ //检查是否有文件夹
+ String folderName = savePath + type;
+ File folder = new File(folderName);
+ //没有则创建
+ if (!folder.exists() && !folder.isDirectory()) {
+ LOG.info("创建文件夹:" + folderName);
+ folder.mkdir();
+ }
+
+ SimpleDateFormat bartDateFormat = new SimpleDateFormat
+ ("yyyyMMddHHmmss");
+ newFileName = String.valueOf(bartDateFormat.format(new Date()));
+ filePath = filePath + newFileName + "_" + Math.round(Math.random()*1000);
+ LOG.info("上传文件: " + filePath);
+ FileUtils.writeByteArrayToFile(new File(savePath + filePath), file.getBytes());
+
+ }
+ } catch (Exception e) {
+ LOG.error("Fail to upload file ",e);
+ }
+ return SON_PATH + filePath;
+
+ }
+}
diff --git a/src/main/java/com/cloud/controller/wxsubscribe/WxSubscribeController.java b/src/main/java/com/cloud/controller/wxsubscribe/WxSubscribeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..7fdfbdfdc11062cf5b9f17bd2256d1606dd8fc48
--- /dev/null
+++ b/src/main/java/com/cloud/controller/wxsubscribe/WxSubscribeController.java
@@ -0,0 +1,125 @@
+package com.cloud.controller.wxsubscribe;
+
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.model.view.wxsubscribe.WxSubscribeView;
+import com.cloud.service.wxsubscribe.WxSubscribeService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * WxSubscribeController
+ *
+ * WxSubscribe的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2020-01-11 17:45:41.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]订阅消息接口",tags = "[Cloud Source]订阅消息接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class WxSubscribeController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(WxSubscribeController.class);
+
+ /** The service. */
+ @Autowired
+ private WxSubscribeService wxSubscribeService;
+
+ @ApiOperation(value = "[Cloud Source]创建订阅消息", notes = "创建一个订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxsubscribes", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createWxSubscribe(
+ @ApiParam(value = "订阅消息", required = true) @RequestBody WxSubscribeView wxSubscribeView) {
+ try {
+ // 保存实体
+ WxSubscribeView wxSubscribeViewReturn = wxSubscribeService.saveEntity(wxSubscribeView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS,wxSubscribeViewReturn);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除订阅消息", notes = "通过id删除订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxsubscribes/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxSubscribe(
+ @ApiParam(value = "订阅消息id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ wxSubscribeService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除订阅消息", notes = "批量删除订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxsubscribes", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxSubscribes(
+ @ApiParam(value = "订阅消息ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ wxSubscribeService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新订阅消息", notes = "更新订阅消息信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/wxsubscribes/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateWxSubscribes(
+ @ApiParam(value = "订阅消息id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "订阅消息信息", required = true) @RequestBody WxSubscribeView wxSubscribeView) {
+ try {
+ wxSubscribeView.setId(id);
+ wxSubscribeService.updateEntity(wxSubscribeView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS, wxSubscribeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个订阅消息", notes = "通过id获取订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxsubscribes/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getWxSubscribe(
+ @ApiParam(value = "订阅消息id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final WxSubscribeView wxSubscribeView = wxSubscribeService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, wxSubscribeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/wxuser/WxUserController.java b/src/main/java/com/cloud/controller/wxuser/WxUserController.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3294a86604a150c6fec6e87cef151f309f5d120
--- /dev/null
+++ b/src/main/java/com/cloud/controller/wxuser/WxUserController.java
@@ -0,0 +1,151 @@
+package com.cloud.controller.wxuser;
+
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.model.view.wxuser.WxUserView;
+import com.cloud.service.wxuser.WxUserService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.util.Base64Utils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * WxUserController
+ *
+ * WxUser的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2019-10-15 16:15:58.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]微信用户表接口",tags = "[Cloud Source]微信用户表接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class WxUserController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(WxUserController.class);
+
+ /** The service. */
+ @Autowired
+ private WxUserService wxUserService;
+
+ @ApiOperation(value = "[Cloud Source]创建微信用户表", notes = "创建一个微信用户表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusers", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createWxUser(
+ @ApiParam(value = "微信用户表", required = true) @RequestBody WxUserView wxUserView) {
+ try {
+ // 保存实体
+ WxUserView wxUserView1 = wxUserService.saveEntity(wxUserView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS, wxUserView1);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除微信用户表", notes = "通过id删除微信用户表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusers/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxUser(
+ @ApiParam(value = "微信用户表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ wxUserService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除微信用户表", notes = "批量删除微信用户表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusers", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxUsers(
+ @ApiParam(value = "微信用户表ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ wxUserService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新微信用户表", notes = "更新微信用户表信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/wxusers/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateWxUsers(
+ @ApiParam(value = "微信用户表id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "微信用户表信息", required = true) @RequestBody WxUserView wxUserView) {
+ try {
+ wxUserView.setId(id);
+ wxUserService.updateEntity(wxUserView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS,wxUserView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个微信用户表", notes = "通过id获取微信用户表")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusers/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getWxUser(
+ @ApiParam(value = "微信用户表id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final WxUserView wxUserView = wxUserService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, wxUserView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+
+ /**
+ * 通过code获取用户openId
+ * @param code
+ * @return
+ */
+ @ApiOperation(value = "通过code进行登录操作", notes = "通过code进行登录操作")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error")})
+ @RequestMapping(value = "/v1/wxusers", method = RequestMethod.GET)
+ public Result> userLoginByCode(@ApiParam(value = "code", required = true) @RequestParam String code) {
+ try {
+ WxUserView wxUserView = wxUserService.checkUserLogin(code);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_INSERT_SUCCESS,wxUserView);
+ } catch (Exception e) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500,e.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/controller/wxusersubscribe/WxUserSubscribeController.java b/src/main/java/com/cloud/controller/wxusersubscribe/WxUserSubscribeController.java
new file mode 100644
index 0000000000000000000000000000000000000000..2839336d02dfe7c3b822d70f0298cf7506e27244
--- /dev/null
+++ b/src/main/java/com/cloud/controller/wxusersubscribe/WxUserSubscribeController.java
@@ -0,0 +1,125 @@
+package com.cloud.controller.wxusersubscribe;
+
+import com.cloud.commons.utils.message.Result;
+import com.cloud.commons.utils.message.ResultUtil;
+import com.cloud.commons.utils.message.MessageDescription;
+import com.cloud.commons.utils.message.MessageCode;
+import com.cloud.model.view.wxusersubscribe.WxUserSubscribeView;
+import com.cloud.service.wxusersubscribe.WxUserSubscribeService;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * WxUserSubscribeController
+ *
+ * WxUserSubscribe的具体实现的Api类,提供统一的api调用
+ *
+ * Creation Time: 2020-01-12 00:22:03.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Api(value = "[Cloud Source]用户订阅消息接口",tags = "[Cloud Source]用户订阅消息接口",description = "")
+@RestController
+@RequestMapping(value = "/api")
+public class WxUserSubscribeController {
+
+ /** The Constant LOG. */
+ private static final Logger LOG = LoggerFactory
+ .getLogger(WxUserSubscribeController.class);
+
+ /** The service. */
+ @Autowired
+ private WxUserSubscribeService wxUserSubscribeService;
+
+ @ApiOperation(value = "[Cloud Source]创建用户订阅消息", notes = "创建一个用户订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 201, message = "successful operation", responseHeaders = @ResponseHeader(name = "location", description = "URL of new created resource", response = String.class) ),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusersubscribes", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> createWxUserSubscribe(
+ @ApiParam(value = "用户订阅消息", required = true) @RequestBody WxUserSubscribeView wxUserSubscribeView) {
+ try {
+ // 保存实体
+ WxUserSubscribeView wxUserSubscribeViewReturn = wxUserSubscribeService.saveEntity(wxUserSubscribeView);
+
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200, MessageDescription.OPERATION_INSERT_SUCCESS,wxUserSubscribeViewReturn);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户订阅消息", notes = "通过id删除用户订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusersubscribes/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxUserSubscribe(
+ @ApiParam(value = "用户订阅消息id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ wxUserSubscribeService.deleteEntity(id);
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]删除用户订阅消息", notes = "批量删除用户订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusersubscribes", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> deleteWxUserSubscribes(
+ @ApiParam(value = "用户订阅消息ids,样例 - 1,2,3", required = true) @RequestParam(value = "condition", required = true) String condition) {
+ try {
+ wxUserSubscribeService.deleteEntities(condition);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_DELETE_SUCCESS,null);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]更新用户订阅消息", notes = "更新用户订阅消息信息")
+ @ApiResponses(value = { @ApiResponse(code = 200, message = "successful"),
+ @ApiResponse(code = 404, message = "not found"),
+ @ApiResponse(code = 409, message = "conflict"),
+ @ApiResponse(code = 500, message = "internal Server Error") })
+ @RequestMapping(value = "/v1/wxusersubscribes/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> updateWxUserSubscribes(
+ @ApiParam(value = "用户订阅消息id", required = true) @PathVariable(value = "id") Long id,
+ @ApiParam(value = "用户订阅消息信息", required = true) @RequestBody WxUserSubscribeView wxUserSubscribeView) {
+ try {
+ wxUserSubscribeView.setId(id);
+ wxUserSubscribeService.updateEntity(wxUserSubscribeView);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_UPDATE_SUCCESS, wxUserSubscribeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "[Cloud Source]获取单个用户订阅消息", notes = "通过id获取用户订阅消息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error") })
+ @RequestMapping(value = "/v1/wxusersubscribes/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+ public Result> getWxUserSubscribe(
+ @ApiParam(value = "用户订阅消息id", required = true) @PathVariable(value = "id") Long id) {
+ try {
+ final WxUserSubscribeView wxUserSubscribeView = wxUserSubscribeService.getEntity(id);
+ // 封装返回信息
+ return ResultUtil.success(MessageCode.SUCCESS_CODE_200,MessageDescription.OPERATION_QUERY_SUCCESS, wxUserSubscribeView);
+ } catch (Exception t) {
+ return ResultUtil.error(MessageCode.ERROR_CODE_500, t.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/com/cloud/dao/accesstoken/AccessTokenDao.java b/src/main/java/com/cloud/dao/accesstoken/AccessTokenDao.java
new file mode 100644
index 0000000000000000000000000000000000000000..33bb8b1760f472850bbf7f87ee0498d3a4f63805
--- /dev/null
+++ b/src/main/java/com/cloud/dao/accesstoken/AccessTokenDao.java
@@ -0,0 +1,9 @@
+package com.cloud.dao.accesstoken;
+
+import com.cloud.model.entity.accesstoken.AccessToken;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface AccessTokenDao extends JpaRepository {
+}
diff --git a/src/main/java/com/cloud/dao/assets/AssetsDao.java b/src/main/java/com/cloud/dao/assets/AssetsDao.java
new file mode 100644
index 0000000000000000000000000000000000000000..f4142e2fb8e4091a0c62fb1e8b9df36c2e325273
--- /dev/null
+++ b/src/main/java/com/cloud/dao/assets/AssetsDao.java
@@ -0,0 +1,39 @@
+package com.cloud.dao.assets;
+
+import com.cloud.model.entity.assets.Assets;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+/**
+ * AssetsDao
+ *
+ * Assets的具体实现
+ *
+ * Creation Time: 2019-10-15 17:21:44.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Repository
+public interface AssetsDao extends JpaRepository, JpaSpecificationExecutor {
+
+
+ /**
+ * 更新金额信息
+ * @param totalIncome
+ * @param totalExpenditure
+ * @param totalMoney
+ * @param currentTimeMillis
+ * @param assetsId
+ */
+ @Modifying
+ @Query(value = "update t_assets set total_income = ?1,total_expenditure = ?2,total_money = ?3,update_time = ?4 where id = ?5",nativeQuery = true)
+ void updateAssetsMoneyAndUpdateTime(Long totalIncome, Long totalExpenditure, Long totalMoney, long currentTimeMillis, Long assetsId);
+
+
+ Assets findByUserId(Long userId);
+}
diff --git a/src/main/java/com/cloud/dao/assetsdetail/AssetsDetailDao.java b/src/main/java/com/cloud/dao/assetsdetail/AssetsDetailDao.java
new file mode 100644
index 0000000000000000000000000000000000000000..a1372165a5ee9aba70936ee751fb884b0424a941
--- /dev/null
+++ b/src/main/java/com/cloud/dao/assetsdetail/AssetsDetailDao.java
@@ -0,0 +1,85 @@
+package com.cloud.dao.assetsdetail;
+
+import com.cloud.model.entity.assetsdetail.AssetsDetail;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+import sun.awt.SunHints;
+
+import javax.transaction.Transactional;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AssetsDetailDao
+ *
+ * AssetsDetail的具体实现
+ *
+ * Creation Time: 2019-10-15 17:22:19.
+ *
+ * @author ${model.author}
+ * @version 1.0.0
+ * @since cloud-spring-boot-be 1.0.0
+ */
+@Repository
+public interface AssetsDetailDao extends JpaRepository, JpaSpecificationExecutor {
+
+ AssetsDetail findByUserIdAndNowFirstMonth(Long userId,Long nowFirstMonth);
+
+
+ @Modifying
+ @Query(value = "update t_assets set total_income = ?1, total_expenditure = ?2, total_money = ?3,update_time = ?4 where id = ?5",nativeQuery = true)
+ void updateAssetsMoneyAndUpdateTime(Long totalIncome,Long totalExpenditure,Long totalMoney,Long updateTime,Long id);
+
+ @Query(value = "select sum(month_total_income) as income,sum(month_total_expenditure) as expenditure,sum(month_total_money) as money from t_assets_detail where assets_id = ?1",nativeQuery = true)
+ Map sunMoneyByAssetsId(Long assetsId);
+
+ AssetsDetail findByAssetsIdAndNowFirstMonth(Long id,Long nowFirstMonth);
+
+ AssetsDetail findByEnabledAndUserIdAndNowFirstMonth(Integer enabled, Long userId, Long monthFirst);
+
+ List findByAssetsId(Long id);
+
+ @Query(value = "SELECT a.categorie, IFNULL(b.pay, 0) AS 'pay',IFNULL(b.income,0) AS 'income' ,(IFNULL(b.income,0) - IFNULL(b.pay,0)) AS 'totalMoney' FROM (\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 0 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 1 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 2 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 3 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 4 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 5 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 6 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 7 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 8 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 9 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 10 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 11 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 12 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 13 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 14 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 15 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 16 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 17 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 18 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 19 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 20 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 21 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 22 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 23 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 24 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 25 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 26 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 27 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 28 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 29 DAY ) as categorie UNION ALL\n" +
+ " SELECT DATE_ADD(FROM_UNIXTIME(?1 / 1000, '%Y-%m-%d'),INTERVAL + 30 DAY ) as categorie ) AS a \n" +
+ " LEFT JOIN (\n" +
+ " SELECT FROM_UNIXTIME(tb.consume_time_day /1000,'%Y-%m-%d') AS datetime,sum(if(tct.type = 0,tb.money,0)) AS 'pay', sum(if(tct.type = 1,tb.money,0)) AS 'income'\n" +
+ " FROM t_bookkeeping as tb\n" +
+ " left join t_consume_type tct on tb.consume_type_id = tct.id\n" +
+ " where tb.user_id = ?2 and tb.consume_time_day in ?3\n" +
+ " GROUP BY tb.consume_time_day\n" +
+ " ) AS b ON a.categorie = b.datetime group by a.categorie asc\n",nativeQuery = true)
+ List