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> findByNowFirstMonthAndUserIdAndMonthValues(Long startTimeValue, Long userId, List nowTimesValue); +} diff --git a/src/main/java/com/cloud/dao/bookkeeping/BookkeepingDao.java b/src/main/java/com/cloud/dao/bookkeeping/BookkeepingDao.java new file mode 100644 index 0000000000000000000000000000000000000000..528669d5bd14fc6bcbc336c5f4c7ec8ad2ef14e0 --- /dev/null +++ b/src/main/java/com/cloud/dao/bookkeeping/BookkeepingDao.java @@ -0,0 +1,64 @@ +package com.cloud.dao.bookkeeping; + +import com.cloud.model.entity.bookkeeping.Bookkeeping; +import com.cloud.model.view.comsumepie.ComsumePieView; +import com.cloud.model.view.consumetype.ConsumeTypeView; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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 org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +/** + * BookkeepingDao + *

+ * Bookkeeping的具体实现 + *

+ * Creation Time: 2019-10-15 17:24:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface BookkeepingDao extends JpaRepository, JpaSpecificationExecutor { + + @Query(value = "select sum(if(tct.type = 0,tb.money,0)) as expenditure,sum(if(tct.type = 1,tb.money,0)) as income from t_bookkeeping as tb\n" + + "left join t_consume_type tct on tb.consume_type_id = tct.id where tb.user_id = ?1 and tb.consume_time between ?2 and ?3", nativeQuery = true) + Map sunByUserIdAndConsumeTimeBetween(Long userId, Long startTime, Long endTime); + + Page findAllByUserIdAndEnabledOrderByConsumeTimeDesc(Long userId, Integer enabled, Pageable pageable); + + @Query(value = "select sum(money) from t_bookkeeping where enabled = ?1 and user_id = ?2 and consume_time between ?3 and ?4",nativeQuery = true) + Integer sunByEnabledAndUserIdAndConsumeTimeBetween(Integer enabled, Long userId, Long dayStartTime, Long dayEndTime); + + @Modifying + @Transactional + @Query(value = "update t_bookkeeping set is_show_time = 0,update_time = ?1 where user_id= ?2 and is_show_time = ?3 and consume_time between ?4 and ?5",nativeQuery = true) + void updateIsShowTimeByUserIdAndIsShowTimeAndConsumeTimeBetween(Long currentTimeMillis,Long userId, Integer enabled, Long currentStartTime, Long currentEndTime); + + List findByUserIdAndIsShowTimeAndConsumeTimeBetweenOrderByWeightDesc(Long userId, Integer isShowTime, Long currentStartTime, Long currentEndTime); + + @Modifying + @Transactional + @Query(value = "update t_bookkeeping set is_show_time = ?1,update_time = ?2 where id= ?3",nativeQuery = true) + void updateIsShowTimeById(Integer enabled, long currentTimeMillis, Long id); + + @Query(value = "select new com.cloud.model.view.comsumepie.ComsumePieView(SUM(tb.money),tct.name) from Bookkeeping as tb " + + "left join ConsumeType tct on tb.consumeTypeId = tct.id " + + "where tb.userId = ?1 and tct.type = ?4 and tb.consumeTime between ?2 and ?3 " + + "group by tct.id ") + List countMoneyByConsumeTimeAndUserId(Long userId, Long startTimeValue, Long endTimeValue, Integer type); + + @Query(value = "select consume_time from t_bookkeeping where user_id = ?1 and enabled = ?2 order by consume_time desc limit 0 ,1;",nativeQuery = true) + Long findOneByUserIdAndEnabledOrderByConsumeTimeDesc(Long userId, Integer enabled); + + @Query(value = "select consume_time from t_bookkeeping where user_id = ?1 and enabled = ?2 order by consume_time asc limit 0 ,1;",nativeQuery = true) + Long findOneByUserIdAndEnabledOrderByConsumeTimeAsc(Long userId, Integer enabled); +} diff --git a/src/main/java/com/cloud/dao/city/CityDao.java b/src/main/java/com/cloud/dao/city/CityDao.java new file mode 100644 index 0000000000000000000000000000000000000000..ae1fa301bf9cedac537473cd9e3bf295e9aa9253 --- /dev/null +++ b/src/main/java/com/cloud/dao/city/CityDao.java @@ -0,0 +1,22 @@ +package com.cloud.dao.city; + +import com.cloud.model.entity.city.City; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * CityDao + *

+ * City的具体实现 + *

+ * Creation Time: 2019-10-16 14:30:33. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface CityDao extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/cloud/dao/cityweather/CityWeatherDao.java b/src/main/java/com/cloud/dao/cityweather/CityWeatherDao.java new file mode 100644 index 0000000000000000000000000000000000000000..bf12edcdc2de5aecdd95d5074f5307ce410b6ccc --- /dev/null +++ b/src/main/java/com/cloud/dao/cityweather/CityWeatherDao.java @@ -0,0 +1,23 @@ +package com.cloud.dao.cityweather; + +import com.cloud.model.entity.cityweather.CityWeather; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * CityWeatherDao + *

+ * CityWeather的具体实现 + *

+ * Creation Time: 2019-10-16 14:31:05. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface CityWeatherDao extends JpaRepository, JpaSpecificationExecutor { + + CityWeather findByCityIdAndWeatherType(Long cityId,String type); +} diff --git a/src/main/java/com/cloud/dao/consumetype/ConsumeTypeDao.java b/src/main/java/com/cloud/dao/consumetype/ConsumeTypeDao.java new file mode 100644 index 0000000000000000000000000000000000000000..d8f257572b963ec55737259240012bbed6b8fea8 --- /dev/null +++ b/src/main/java/com/cloud/dao/consumetype/ConsumeTypeDao.java @@ -0,0 +1,25 @@ +package com.cloud.dao.consumetype; + +import com.cloud.model.entity.consumetype.ConsumeType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * ConsumeTypeDao + *

+ * ConsumeType的具体实现 + *

+ * Creation Time: 2019-10-15 17:23:42. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface ConsumeTypeDao extends JpaRepository, JpaSpecificationExecutor { + + List findAllByEnabledAndTypeOrderByWeightDesc(Integer enabled, Integer type); +} diff --git a/src/main/java/com/cloud/dao/wxsubscribe/WxSubscribeDao.java b/src/main/java/com/cloud/dao/wxsubscribe/WxSubscribeDao.java new file mode 100644 index 0000000000000000000000000000000000000000..3c9ea37bf9fd75ccabe489737bfcf5e8affc1ce9 --- /dev/null +++ b/src/main/java/com/cloud/dao/wxsubscribe/WxSubscribeDao.java @@ -0,0 +1,22 @@ +package com.cloud.dao.wxsubscribe; + +import com.cloud.model.entity.wxsubscribe.WxSubscribe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * WxSubscribeDao + *

+ * WxSubscribe的具体实现 + *

+ * Creation Time: 2020-01-11 17:45:41. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface WxSubscribeDao extends JpaRepository, JpaSpecificationExecutor { + +} diff --git a/src/main/java/com/cloud/dao/wxuser/WxUserDao.java b/src/main/java/com/cloud/dao/wxuser/WxUserDao.java new file mode 100644 index 0000000000000000000000000000000000000000..f78436552e68b10d74303a3c3fc1427ab1ae561d --- /dev/null +++ b/src/main/java/com/cloud/dao/wxuser/WxUserDao.java @@ -0,0 +1,22 @@ +package com.cloud.dao.wxuser; + +import com.cloud.model.entity.wxuser.WxUser; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * WxUserDao + *

+ * WxUser的具体实现 + *

+ * Creation Time: 2019-10-15 16:15:58. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface WxUserDao extends JpaRepository, JpaSpecificationExecutor { + WxUser findByOpenId(String openId); +} diff --git a/src/main/java/com/cloud/dao/wxusersubscribe/WxUserSubscribeDao.java b/src/main/java/com/cloud/dao/wxusersubscribe/WxUserSubscribeDao.java new file mode 100644 index 0000000000000000000000000000000000000000..bb24e8a80e40b828b82eb4b51b59eb5e20926276 --- /dev/null +++ b/src/main/java/com/cloud/dao/wxusersubscribe/WxUserSubscribeDao.java @@ -0,0 +1,23 @@ +package com.cloud.dao.wxusersubscribe; + +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +/** + * WxUserSubscribeDao + *

+ * WxUserSubscribe的具体实现 + *

+ * Creation Time: 2020-01-12 00:22:03. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Repository +public interface WxUserSubscribeDao extends JpaRepository, JpaSpecificationExecutor { + + WxUserSubscribe findByUserIdAndSubscribeId(Long userId, String subscribeId); +} diff --git a/src/main/java/com/cloud/model/entity/accesstoken/AccessToken.java b/src/main/java/com/cloud/model/entity/accesstoken/AccessToken.java new file mode 100644 index 0000000000000000000000000000000000000000..156a9a37d8f15576879fd4280b8377f0a9268ef6 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/accesstoken/AccessToken.java @@ -0,0 +1,35 @@ +package com.cloud.model.entity.accesstoken; + +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; + +import javax.persistence.Column; +import javax.persistence.Entity; + +@Entity(name = "t_access_token") +public class AccessToken extends BaseEntity{ + + @ApiModelProperty("token有效时间") + @Column(name = "expires_in") + private Integer expiresIn; + + @ApiModelProperty("微信AccessToken") + @Column(name = "access_token") + private String accessToken; + + public Integer getExpiresIn() { + return expiresIn; + } + + public void setExpiresIn(Integer expiresIn) { + this.expiresIn = expiresIn; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } +} diff --git a/src/main/java/com/cloud/model/entity/assets/Assets.java b/src/main/java/com/cloud/model/entity/assets/Assets.java new file mode 100644 index 0000000000000000000000000000000000000000..4a1ada2ed56746a3ee859b229651e16216bb224f --- /dev/null +++ b/src/main/java/com/cloud/model/entity/assets/Assets.java @@ -0,0 +1,86 @@ +package com.cloud.model.entity.assets; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Assets + *

+ * Assets的具体实现 + *

+ * Creation Time: 2019-10-15 17:21:44. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_assets") +@DynamicInsert +@DynamicUpdate +public class Assets extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "total_money") + @ApiModelProperty(value = "总金额") + private Long totalMoney; + + @Column(name = "total_expenditure") + @ApiModelProperty(value = "总支出") + private Long totalExpenditure; + + @Column(name = "total_income") + @ApiModelProperty(value = "总收入") + private Long totalIncome; + + @Column(name = "user_id") + @ApiModelProperty(value = "用户id") + private Long userId; + + public Long getTotalMoney() { + return totalMoney; + } + + public void setTotalMoney(Long totalMoney) { + this.totalMoney = totalMoney; + } + + public Long getTotalExpenditure() { + return totalExpenditure; + } + + public void setTotalExpenditure(Long totalExpenditure) { + this.totalExpenditure = totalExpenditure; + } + + public Long getTotalIncome() { + return totalIncome; + } + + public void setTotalIncome(Long totalIncome) { + this.totalIncome = totalIncome; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Assets(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/assetsdetail/AssetsDetail.java b/src/main/java/com/cloud/model/entity/assetsdetail/AssetsDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..8f09fc6a91775f6548b8292d53ed6658e55b41d9 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/assetsdetail/AssetsDetail.java @@ -0,0 +1,122 @@ +package com.cloud.model.entity.assetsdetail; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * AssetsDetail + *

+ * AssetsDetail的具体实现 + *

+ * Creation Time: 2019-10-15 17:22:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_assets_detail") +@DynamicInsert +@DynamicUpdate +public class AssetsDetail extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "month_total_money") + @ApiModelProperty(value = "月总金额") + private Long monthTotalMoney; + + @Column(name = "month_total_expenditure") + @ApiModelProperty(value = "月总支出") + private Long monthTotalExpenditure; + + @Column(name = "month_total_income") + @ApiModelProperty(value = "月总收入") + private Long monthTotalIncome; + + @Column(name = "user_id") + @ApiModelProperty(value = "用户id") + private Long userId; + + @Column(name = "now_month") + @ApiModelProperty(value = "当前月份") + private String nowMonth; + + @Column(name = "now_first_month") + @ApiModelProperty(value = "当前月份初始时间时间戳") + private Long nowFirstMonth; + + @Column(name = "assets_id") + @ApiModelProperty(value = "assets_id") + private Long assetsId; + + public Long getMonthTotalMoney() { + return monthTotalMoney; + } + + public void setMonthTotalMoney(Long monthTotalMoney) { + this.monthTotalMoney = monthTotalMoney; + } + + public Long getMonthTotalExpenditure() { + return monthTotalExpenditure; + } + + public void setMonthTotalExpenditure(Long monthTotalExpenditure) { + this.monthTotalExpenditure = monthTotalExpenditure; + } + + public Long getMonthTotalIncome() { + return monthTotalIncome; + } + + public void setMonthTotalIncome(Long monthTotalIncome) { + this.monthTotalIncome = monthTotalIncome; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getNowMonth() { + return nowMonth; + } + + public void setNowMonth(String nowMonth) { + this.nowMonth = nowMonth; + } + + public Long getNowFirstMonth() { + return nowFirstMonth; + } + + public void setNowFirstMonth(Long nowFirstMonth) { + this.nowFirstMonth = nowFirstMonth; + } + + public Long getAssetsId() { + return assetsId; + } + + public void setAssetsId(Long assetsId) { + this.assetsId = assetsId; + } + + public AssetsDetail(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/base/BaseEntity.java b/src/main/java/com/cloud/model/entity/base/BaseEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..0d816f0b2a69f11f5d06af8f3f069dbb38cfc954 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/base/BaseEntity.java @@ -0,0 +1,73 @@ +package com.cloud.model.entity.base; + +import io.swagger.annotations.ApiModelProperty; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@MappedSuperclass +public class BaseEntity { + @Id + @Column(name = "id", unique = true, nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "id") + private Long id; + + @NotNull + @Column(name = "create_time") + @ApiModelProperty(value = "创建时间") + private Long createTime; + @NotNull + @Column(name = "update_time") + @ApiModelProperty(value = "更新时间") + private Long updateTime; + + @Column(name = "enabled") + @ApiModelProperty(value = "状态 0:不可见 1:可见") + private Integer enabled; + + @Column(name = "weight") + @ApiModelProperty(value = "权重 权重越大排名越前") + private Long weight; + + + public Long getWeight() { + return weight; + } + + public void setWeight(Long weight) { + this.weight = weight; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } + + public Integer getEnabled() { + return enabled; + } + + public void setEnabled(Integer enabled) { + this.enabled = enabled; + } +} diff --git a/src/main/java/com/cloud/model/entity/bookkeeping/Bookkeeping.java b/src/main/java/com/cloud/model/entity/bookkeeping/Bookkeeping.java new file mode 100644 index 0000000000000000000000000000000000000000..f55b07c5e84054e94ca8776db971463426852bbe --- /dev/null +++ b/src/main/java/com/cloud/model/entity/bookkeeping/Bookkeeping.java @@ -0,0 +1,170 @@ +package com.cloud.model.entity.bookkeeping; + +import com.cloud.model.entity.consumetype.ConsumeType; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Bookkeeping + *

+ * Bookkeeping的具体实现 + *

+ * Creation Time: 2019-10-15 17:24:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_bookkeeping") +@DynamicInsert +@DynamicUpdate +public class Bookkeeping extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + public Bookkeeping(){ + super(); + } + + @Column(name = "money") + @ApiModelProperty(value = "消费金额") + private Long money; + + @Column(name = "consume_time") + @ApiModelProperty(value = "消费日期") + private Long consumeTime; + + @Column(name = "consume_type_id") + @ApiModelProperty(value = "消费类型id") + private Long consumeTypeId; + + @Column(name = "user_id") + @ApiModelProperty(value = "用户id") + private Long userId; + + @Column(name = "is_show_time") + @ApiModelProperty(value = "前端判断是否显示消费时间:0:否,1:是") + private Integer isShowTime; + + @Column(name = "image_url") + @ApiModelProperty(value = "图片List保存") + private String imageUrl; + + @Column(name = "address") + @ApiModelProperty(value = "消费地址") + private String address; + + @Column(name = "address_detail") + @ApiModelProperty(value = "详情地址") + private String addressDetail; + + @Column(name = "remarks") + @ApiModelProperty(value = "备注") + private String remarks; + + @Column(name = "consume_time_day") + @ApiModelProperty(value = "消费的日期,取当天凌晨时间戳") + private Long consumeTimeDay; + + @ManyToOne + @JoinColumn(name = "consume_type_id",insertable = false,updatable = false) + private ConsumeType consumeType; + + public String getAddressDetail() { + return addressDetail; + } + + public void setAddressDetail(String addressDetail) { + this.addressDetail = addressDetail; + } + + public Long getConsumeTimeDay() { + return consumeTimeDay; + } + + public void setConsumeTimeDay(Long consumeTimeDay) { + this.consumeTimeDay = consumeTimeDay; + } + + public ConsumeType getConsumeType() { + return consumeType; + } + + public void setConsumeType(ConsumeType consumeType) { + this.consumeType = consumeType; + } + + public Long getMoney() { + return money; + } + + public void setMoney(Long money) { + this.money = money; + } + + public Long getConsumeTime() { + return consumeTime; + } + + public void setConsumeTime(Long consumeTime) { + this.consumeTime = consumeTime; + } + + public Long getConsumeTypeId() { + return consumeTypeId; + } + + public void setConsumeTypeId(Long consumeTypeId) { + this.consumeTypeId = consumeTypeId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Integer getIsShowTime() { + return isShowTime; + } + + public void setIsShowTime(Integer isShowTime) { + this.isShowTime = isShowTime; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } +} diff --git a/src/main/java/com/cloud/model/entity/city/City.java b/src/main/java/com/cloud/model/entity/city/City.java new file mode 100644 index 0000000000000000000000000000000000000000..6b2460e002549f1997a3c1650b859c8a50c4a41d --- /dev/null +++ b/src/main/java/com/cloud/model/entity/city/City.java @@ -0,0 +1,62 @@ +package com.cloud.model.entity.city; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * City + *

+ * City的具体实现 + *

+ * Creation Time: 2019-10-16 14:30:33. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_city") +@DynamicInsert +@DynamicUpdate +public class City extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "city") + @ApiModelProperty(value = "城市") + private String city; + + @Column(name = "area") + @ApiModelProperty(value = "市区") + private String area; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public City(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/cityweather/CityWeather.java b/src/main/java/com/cloud/model/entity/cityweather/CityWeather.java new file mode 100644 index 0000000000000000000000000000000000000000..eff209e0adcfd4acc48d600c9d0624da79b9e67e --- /dev/null +++ b/src/main/java/com/cloud/model/entity/cityweather/CityWeather.java @@ -0,0 +1,73 @@ +package com.cloud.model.entity.cityweather; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * CityWeather + *

+ * CityWeather的具体实现 + *

+ * Creation Time: 2019-10-16 14:31:05. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_city_weather") +@DynamicInsert +@DynamicUpdate +public class CityWeather extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + public CityWeather(){ + super(); + } + + @Column(name = "weather_result_json") + @ApiModelProperty(value = "和风天气返回的json数据") + private String weatherResultJson; + + @Column(name = "weatherType") + @ApiModelProperty(value = "天气数据类型 now:实况天气 forecast:3-10天预报 hourly:逐小时预报 lifestyle:生活指数") + private String weatherType; + + @Column(name = "city_id") + @ApiModelProperty(value = "城市id") + private Long cityId; + + public String getWeatherResultJson() { + return weatherResultJson; + } + + public void setWeatherResultJson(String weatherResultJson) { + this.weatherResultJson = weatherResultJson; + } + + public String getWeatherType() { + return weatherType; + } + + public void setWeatherType(String weatherType) { + this.weatherType = weatherType; + } + + public Long getCityId() { + return cityId; + } + + public void setCityId(Long cityId) { + this.cityId = cityId; + } +} diff --git a/src/main/java/com/cloud/model/entity/consumetype/ConsumeType.java b/src/main/java/com/cloud/model/entity/consumetype/ConsumeType.java new file mode 100644 index 0000000000000000000000000000000000000000..48555faa5bfb0b0710af80767c14efaae338823a --- /dev/null +++ b/src/main/java/com/cloud/model/entity/consumetype/ConsumeType.java @@ -0,0 +1,86 @@ +package com.cloud.model.entity.consumetype; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * ConsumeType + *

+ * ConsumeType的具体实现 + *

+ * Creation Time: 2019-10-15 17:23:42. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_consume_type") +@DynamicInsert +@DynamicUpdate +public class ConsumeType extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "icon") + @ApiModelProperty(value = "icon地址") + private String icon; + + @Column(name = "icon_1") + @ApiModelProperty(value = "icon_1地址") + private String icon1; + + @Column(name = "type") + @ApiModelProperty(value = "消费类型 0:支出 1:收入") + private Integer type; + + @Column(name = "name") + @ApiModelProperty(value = "名称") + private String name; + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getIcon1() { + return icon1; + } + + public void setIcon1(String icon1) { + this.icon1 = icon1; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ConsumeType(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/wxmintemplateproject/WxMinTemplateProject.java b/src/main/java/com/cloud/model/entity/wxmintemplateproject/WxMinTemplateProject.java new file mode 100644 index 0000000000000000000000000000000000000000..4fa4c1eaf0a1dc961278b926e1dc671d31195eb1 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/wxmintemplateproject/WxMinTemplateProject.java @@ -0,0 +1,75 @@ +package com.cloud.model.entity.wxmintemplateproject; + +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Map; + +public class WxMinTemplateProject { + @ApiModelProperty("需要发送的模板id") + private String templateId; + + @ApiModelProperty("调用凭证accessToken") + private String accessToken; + + @ApiModelProperty("发送用户的openId") + private String openId; + + @ApiModelProperty("跳转页面(可不传)") + private String page; + + @ApiModelProperty("需要设置的模板消息内容") + private List keywordData; + + + public WxMinTemplateProject() { + } + + public WxMinTemplateProject(String templateId, String openId, String page, List keywordData) { + this.templateId = templateId; + this.openId = openId; + this.page = page; + this.keywordData = keywordData; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getPage() { + return page; + } + + public void setPage(String page) { + this.page = page; + } + + public List getKeywordData() { + return keywordData; + } + + public void setKeywordData(List keywordData) { + this.keywordData = keywordData; + } +} diff --git a/src/main/java/com/cloud/model/entity/wxsubscribe/WxSubscribe.java b/src/main/java/com/cloud/model/entity/wxsubscribe/WxSubscribe.java new file mode 100644 index 0000000000000000000000000000000000000000..52d967d38166ecf49de786419c1b4351c7e51146 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/wxsubscribe/WxSubscribe.java @@ -0,0 +1,37 @@ +package com.cloud.model.entity.wxsubscribe; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * WxSubscribe + *

+ * WxSubscribe的具体实现 + *

+ * Creation Time: 2020-01-11 17:45:41. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_wx_subscribe") +@DynamicInsert +@DynamicUpdate +public class WxSubscribe extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + public WxSubscribe(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/wxuser/WxUser.java b/src/main/java/com/cloud/model/entity/wxuser/WxUser.java new file mode 100644 index 0000000000000000000000000000000000000000..1bbadbb504951d08cce6fc722a1a734115914ed1 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/wxuser/WxUser.java @@ -0,0 +1,145 @@ +package com.cloud.model.entity.wxuser; + +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * WxUser + *

+ * WxUser的具体实现 + *

+ * Creation Time: 2019-10-15 16:15:58. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_wx_user") +@DynamicInsert +@DynamicUpdate +public class WxUser extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "open_id") + @ApiModelProperty(value = "微信openId") + private String openId; + + @Column(name = "username") + @ApiModelProperty(value = "用户名") + private String username; + + @Column(name = "nick_name") + @ApiModelProperty(value = "用户微信昵称") + private String nickName; + + @Column(name = "phone") + @ApiModelProperty(value = "电话") + private String phone; + + @Column(name = "avatar_url") + @ApiModelProperty(value = "微信头像地址") + private String avatarUrl; + + @Column(name = "rights") + @ApiModelProperty(value = "用户权限 0:管理员,1:用户") + private Integer rights; + + @Column(name = "login_end_time") + @ApiModelProperty(value = "用户最后一次登录时间") + private Long loginEndTime; + + @Column(name = "month_budget") + @ApiModelProperty(value = "月预算") + private Long monthBudget; + + @Column(name = "send_message") + @ApiModelProperty(value = "发送模板消息") + private Integer sendMessage; + + public Integer getSendMessage() { + return sendMessage; + } + + public void setSendMessage(Integer sendMessage) { + this.sendMessage = sendMessage; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + } + + public Integer getRights() { + return rights; + } + + public void setRights(Integer rights) { + this.rights = rights; + } + + public Long getLoginEndTime() { + return loginEndTime; + } + + public void setLoginEndTime(Long loginEndTime) { + this.loginEndTime = loginEndTime; + } + + public Long getMonthBudget() { + return monthBudget; + } + + public void setMonthBudget(Long monthBudget) { + this.monthBudget = monthBudget; + } + + public WxUser(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/entity/wxusersubscribe/WxUserSubscribe.java b/src/main/java/com/cloud/model/entity/wxusersubscribe/WxUserSubscribe.java new file mode 100644 index 0000000000000000000000000000000000000000..94f4514ac07b15edd2d5a8a541a101618378b625 --- /dev/null +++ b/src/main/java/com/cloud/model/entity/wxusersubscribe/WxUserSubscribe.java @@ -0,0 +1,74 @@ +package com.cloud.model.entity.wxusersubscribe; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.cloud.model.entity.base.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * WxUserSubscribe + *

+ * WxUserSubscribe的具体实现 + *

+ * Creation Time: 2020-01-12 00:22:03. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Entity +@Table(name="t_wx_user_subscribe") +@DynamicInsert +@DynamicUpdate +public class WxUserSubscribe extends BaseEntity implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @Column(name = "subscribe_id") + @ApiModelProperty(value = "模板id") + private String subscribeId; + + @Column(name = "user_id") + @ApiModelProperty(value = "用户id") + private Long userId; + + @Column(name = "type") + @ApiModelProperty(value = "授权状态: 0:拒绝 1:允许 2:后台封禁") + private Integer type; + + public String getSubscribeId() { + return subscribeId; + } + + public void setSubscribeId(String subscribeId) { + this.subscribeId = subscribeId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public WxUserSubscribe(){ + super(); + } + +} diff --git a/src/main/java/com/cloud/model/view/accesstoken/AccessTokenView.java b/src/main/java/com/cloud/model/view/accesstoken/AccessTokenView.java new file mode 100644 index 0000000000000000000000000000000000000000..1ad33855bb5af916e5c5da54996a8a33c4483d4f --- /dev/null +++ b/src/main/java/com/cloud/model/view/accesstoken/AccessTokenView.java @@ -0,0 +1,6 @@ +package com.cloud.model.view.accesstoken; + +import com.cloud.model.entity.accesstoken.AccessToken; + +public class AccessTokenView extends AccessToken { +} diff --git a/src/main/java/com/cloud/model/view/assets/AssetsView.java b/src/main/java/com/cloud/model/view/assets/AssetsView.java new file mode 100644 index 0000000000000000000000000000000000000000..a63e1b1ddb8c631b74b6939a5be65b12665aeab6 --- /dev/null +++ b/src/main/java/com/cloud/model/view/assets/AssetsView.java @@ -0,0 +1,38 @@ +package com.cloud.model.view.assets; + +import com.cloud.model.entity.assets.Assets; +import com.cloud.model.view.assetsdetail.AssetsDetailView; +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; +import java.util.List; + +/** + * AssetsView + *

+ * Assets的具体实现 + *

+ * Creation Time: 2019-10-15 17:21:44. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class AssetsView extends Assets implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + private List assetsDetailViews; + + public List getAssetsDetailViews() { + return assetsDetailViews; + } + + public void setAssetsDetailViews(List assetsDetailViews) { + this.assetsDetailViews = assetsDetailViews; + } +} diff --git a/src/main/java/com/cloud/model/view/assetsdetail/AssetsDetailView.java b/src/main/java/com/cloud/model/view/assetsdetail/AssetsDetailView.java new file mode 100644 index 0000000000000000000000000000000000000000..8bea9aed633a6c506104f6d762535b5363337bb4 --- /dev/null +++ b/src/main/java/com/cloud/model/view/assetsdetail/AssetsDetailView.java @@ -0,0 +1,118 @@ +package com.cloud.model.view.assetsdetail; + +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.view.comsumepie.ComsumePieView; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.List; + +/** + * AssetsDetailView + *

+ * AssetsDetail的具体实现 + *

+ * Creation Time: 2019-10-15 17:22:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class AssetsDetailView extends AssetsDetail implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + + @ApiModelProperty(value = "横纵标表示数值") + List categories; + + @ApiModelProperty(value = "每天总消费数据") + List totalMoneys; + + @ApiModelProperty(value = "每天支出数据") + List pays; + + @ApiModelProperty(value = "每天收入数据") + List incomes; + + @ApiModelProperty(value = "当月支出各个分类所占比重") + List consumePayProportion; + + @ApiModelProperty(value = "当月收入各个分类所占比重") + List consumeIncomeProportion; + + @ApiModelProperty(value = "当前用户消费有效时间-开始时间") + private String billStartTime; + + @ApiModelProperty(value = "当前用户消费有效时间-结束时间") + private String billEndTime; + + public String getBillStartTime() { + return billStartTime; + } + + public void setBillStartTime(String billStartTime) { + this.billStartTime = billStartTime; + } + + public String getBillEndTime() { + return billEndTime; + } + + public void setBillEndTime(String billEndTime) { + this.billEndTime = billEndTime; + } + + public List getConsumePayProportion() { + return consumePayProportion; + } + + public void setConsumePayProportion(List consumePayProportion) { + this.consumePayProportion = consumePayProportion; + } + + public List getConsumeIncomeProportion() { + return consumeIncomeProportion; + } + + public void setConsumeIncomeProportion(List consumeIncomeProportion) { + this.consumeIncomeProportion = consumeIncomeProportion; + } + + public List getCategories() { + return categories; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public List getTotalMoneys() { + return totalMoneys; + } + + public void setTotalMoneys(List totalMoneys) { + this.totalMoneys = totalMoneys; + } + + public List getPays() { + return pays; + } + + public void setPays(List pays) { + this.pays = pays; + } + + public List getIncomes() { + return incomes; + } + + public void setIncomes(List incomes) { + this.incomes = incomes; + } +} diff --git a/src/main/java/com/cloud/model/view/bookkeeping/BookkeepingView.java b/src/main/java/com/cloud/model/view/bookkeeping/BookkeepingView.java new file mode 100644 index 0000000000000000000000000000000000000000..7796c671fb8221233707c62101f5c7edf20bbf88 --- /dev/null +++ b/src/main/java/com/cloud/model/view/bookkeeping/BookkeepingView.java @@ -0,0 +1,52 @@ +package com.cloud.model.view.bookkeeping; + +import com.cloud.model.entity.bookkeeping.Bookkeeping; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.persistence.Column; +import java.io.Serializable; +import java.util.List; + +/** + * BookkeepingView + *

+ * Bookkeeping的具体实现 + *

+ * Creation Time: 2019-10-15 17:24:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class BookkeepingView extends Bookkeeping implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + + @ApiModelProperty(name = "当天总支出") + private Integer totalMoney; + + @ApiModelProperty(name = "当天日期时间") + private String nowDayTime; + + public Integer getTotalMoney() { + return totalMoney; + } + + public void setTotalMoney(Integer totalMoney) { + this.totalMoney = totalMoney; + } + + public String getNowDayTime() { + return nowDayTime; + } + + public void setNowDayTime(String nowDayTime) { + this.nowDayTime = nowDayTime; + } +} diff --git a/src/main/java/com/cloud/model/view/city/CityView.java b/src/main/java/com/cloud/model/view/city/CityView.java new file mode 100644 index 0000000000000000000000000000000000000000..2d7bffd227e247ecb10f9ae3585f5bb91f2b5cca --- /dev/null +++ b/src/main/java/com/cloud/model/view/city/CityView.java @@ -0,0 +1,27 @@ +package com.cloud.model.view.city; + +import com.cloud.model.entity.city.City; +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; + +/** + * CityView + *

+ * City的具体实现 + *

+ * Creation Time: 2019-10-16 14:30:33. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class CityView extends City implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + +} diff --git a/src/main/java/com/cloud/model/view/cityweather/CityWeatherView.java b/src/main/java/com/cloud/model/view/cityweather/CityWeatherView.java new file mode 100644 index 0000000000000000000000000000000000000000..e3fcc3cd89900ca5a38395b380b05bf22b9acac6 --- /dev/null +++ b/src/main/java/com/cloud/model/view/cityweather/CityWeatherView.java @@ -0,0 +1,27 @@ +package com.cloud.model.view.cityweather; + +import com.cloud.model.entity.cityweather.CityWeather; +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; + +/** + * CityWeatherView + *

+ * CityWeather的具体实现 + *

+ * Creation Time: 2019-10-16 14:31:05. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class CityWeatherView extends CityWeather implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + +} diff --git a/src/main/java/com/cloud/model/view/comsumepie/ComsumePieView.java b/src/main/java/com/cloud/model/view/comsumepie/ComsumePieView.java new file mode 100644 index 0000000000000000000000000000000000000000..7d987ddcda53ffbe4d05886f2a76806c33c4664e --- /dev/null +++ b/src/main/java/com/cloud/model/view/comsumepie/ComsumePieView.java @@ -0,0 +1,40 @@ +package com.cloud.model.view.comsumepie; + +import io.swagger.annotations.ApiModelProperty; + +import javax.persistence.Column; + +/** + * 消费统计饼图视图 + */ +public class ComsumePieView { + @ApiModelProperty(name = "当前分类所占金额") + private Long value; + + @ApiModelProperty(value = "名称") + private String name; + + public ComsumePieView(Long value, String name) { + this.value = value; + this.name = name; + } + + public ComsumePieView() { + } + + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/cloud/model/view/consumetype/ConsumeTypeView.java b/src/main/java/com/cloud/model/view/consumetype/ConsumeTypeView.java new file mode 100644 index 0000000000000000000000000000000000000000..83fe54aae0d865fc9ac22b1a0dbbed34428e9a49 --- /dev/null +++ b/src/main/java/com/cloud/model/view/consumetype/ConsumeTypeView.java @@ -0,0 +1,29 @@ +package com.cloud.model.view.consumetype; + +import com.cloud.model.entity.consumetype.ConsumeType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.time.Month; + +/** + * ConsumeTypeView + *

+ * ConsumeType的具体实现 + *

+ * Creation Time: 2019-10-15 17:23:42. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class ConsumeTypeView extends ConsumeType implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + +} diff --git a/src/main/java/com/cloud/model/view/wxsubscribe/WxSubscribeView.java b/src/main/java/com/cloud/model/view/wxsubscribe/WxSubscribeView.java new file mode 100644 index 0000000000000000000000000000000000000000..bc135a56bc2cd1df12e42ed089f73562e76aff07 --- /dev/null +++ b/src/main/java/com/cloud/model/view/wxsubscribe/WxSubscribeView.java @@ -0,0 +1,27 @@ +package com.cloud.model.view.wxsubscribe; + +import com.cloud.model.entity.wxsubscribe.WxSubscribe; +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; + +/** + * WxSubscribeView + *

+ * WxSubscribe的具体实现 + *

+ * Creation Time: 2020-01-11 17:45:41. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class WxSubscribeView extends WxSubscribe implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + +} diff --git a/src/main/java/com/cloud/model/view/wxuser/WxUserView.java b/src/main/java/com/cloud/model/view/wxuser/WxUserView.java new file mode 100644 index 0000000000000000000000000000000000000000..46fdbaf20fc1347f5d4452cebe5b3f7ad44e74ff --- /dev/null +++ b/src/main/java/com/cloud/model/view/wxuser/WxUserView.java @@ -0,0 +1,50 @@ +package com.cloud.model.view.wxuser; + +import com.cloud.model.entity.wxuser.WxUser; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * WxUserView + *

+ * WxUser的具体实现 + *

+ * Creation Time: 2019-10-15 16:15:58. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class WxUserView extends WxUser implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + + @ApiModelProperty(name = "用户登录code") + private String code; + + @ApiModelProperty(name = "token") + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + +} diff --git a/src/main/java/com/cloud/model/view/wxusersubscribe/WxUserSubscribeView.java b/src/main/java/com/cloud/model/view/wxusersubscribe/WxUserSubscribeView.java new file mode 100644 index 0000000000000000000000000000000000000000..20daddec269d5f5dc3221bc9b4a3918b0e38c27b --- /dev/null +++ b/src/main/java/com/cloud/model/view/wxusersubscribe/WxUserSubscribeView.java @@ -0,0 +1,27 @@ +package com.cloud.model.view.wxusersubscribe; + +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; + +/** + * WxUserSubscribeView + *

+ * WxUserSubscribe的具体实现 + *

+ * Creation Time: 2020-01-12 00:22:03. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@ApiModel +public class WxUserSubscribeView extends WxUserSubscribe implements Serializable { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = -1L; + +} diff --git a/src/main/java/com/cloud/scheduled/WeatherScheduled.java b/src/main/java/com/cloud/scheduled/WeatherScheduled.java new file mode 100644 index 0000000000000000000000000000000000000000..b8d8bbf90bcd4a52781748ddb05c2a99931a7e8a --- /dev/null +++ b/src/main/java/com/cloud/scheduled/WeatherScheduled.java @@ -0,0 +1,46 @@ +package com.cloud.scheduled; + +import com.cloud.dao.city.CityDao; +import com.cloud.dao.cityweather.CityWeatherDao; +import com.cloud.model.entity.city.City; +import com.cloud.service.cityweather.CityWeatherService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; + +import java.util.List; + +/** + * 更新天气信息 + */ +@Component +@EnableScheduling +public class WeatherScheduled { + + private static final Logger LOG = LoggerFactory.getLogger(WeatherScheduled.class); + + @Autowired + private CityDao cityDao; + + @Autowired + private CityWeatherService cityWeatherService; + /** + * 每小时执行一次 + */ + @Scheduled(cron = "0 0 * * * ?") + public void UpdateWeatherScheduled() { + LOG.info("开始更新和风天气api信息"); + List cities = cityDao.findAll(); + if (ObjectUtils.isEmpty(cities) || cities.size() == 0) { + LOG.info("城市表没数据!定时器关闭"); + return; + } + cities.forEach(city -> { + cityWeatherService.updateCityWeatherEntiy(city); + }); + } +} diff --git a/src/main/java/com/cloud/service/accesstoken/AccessTokenService.java b/src/main/java/com/cloud/service/accesstoken/AccessTokenService.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f11176ccc520407b4c06dd33bb8e918bcdfb6a --- /dev/null +++ b/src/main/java/com/cloud/service/accesstoken/AccessTokenService.java @@ -0,0 +1,10 @@ +package com.cloud.service.accesstoken; + +import com.cloud.model.view.accesstoken.AccessTokenView; +import com.cloud.service.base.BaseService; + + +public interface AccessTokenService extends BaseService{ + + public String getAccessToken(); +} diff --git a/src/main/java/com/cloud/service/accesstoken/impl/AccessTokenServiceImpl.java b/src/main/java/com/cloud/service/accesstoken/impl/AccessTokenServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3148adb72c87242253adf1555b558f796fc6609d --- /dev/null +++ b/src/main/java/com/cloud/service/accesstoken/impl/AccessTokenServiceImpl.java @@ -0,0 +1,110 @@ +package com.cloud.service.accesstoken.impl; + +import com.cloud.commons.utils.CloudCopyUtils; +import com.cloud.commons.utils.wechat.WeixinUtil; +import com.cloud.dao.accesstoken.AccessTokenDao; +import com.cloud.model.entity.accesstoken.AccessToken; +import com.cloud.service.accesstoken.AccessTokenService; +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.model.view.accesstoken.AccessTokenView; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import java.util.List; +import java.util.Optional; + +@Service +public class AccessTokenServiceImpl implements AccessTokenService { + @Autowired + private AccessTokenDao accessTokenDao; + + @Autowired + private AccessTokenService accessTokenService; + @Override + public AccessTokenView saveEntity(AccessTokenView entity){ + Long currentTime = System.currentTimeMillis(); + AccessToken accessToken = new AccessToken(); + BeanUtils.copyProperties(entity,accessToken); + accessToken.setCreateTime(System.currentTimeMillis()); + accessToken.setCreateTime(currentTime); + accessToken.setUpdateTime(currentTime); + accessToken.setWeight(currentTime); + accessToken.setEnabled(ConsumeConstant.ENABLED); + + AccessToken accessTokenReturn = accessTokenDao.save(accessToken); + BeanUtils.copyProperties(accessTokenReturn,entity); + return entity; + } + + @Override + public void deleteEntity(long id) { + + } + + @Override + public void deleteEntities(String ids) { + + } + + @Override + public void updateEntity(AccessTokenView entity){ + Optional accessTokenOptional = accessTokenDao.findById(entity.getId()); + AccessToken accessToken = accessTokenOptional.orElseThrow(() -> new RuntimeException("获取不到id为:" + entity.getId() + "的数据记录")); + // 进行copy + CloudCopyUtils.copyBean(entity,accessToken); + accessToken.setUpdateTime(System.currentTimeMillis()); + // 进行更新操作 + accessTokenDao.save(accessToken); + } + + @Override + public AccessTokenView getEntity(long id){ + return null; + } + + @Override + public long getEntitiesCount() { + return 0; + } + + @Override + public List findAll() { + return null; + } + + @Override + public String getAccessToken(){ + List accessTokenAll = accessTokenDao.findAll(); + // 判断token不存在重新获取token信息 + if (ObjectUtils.isEmpty(accessTokenAll) && accessTokenAll.size() == 0) { + AccessToken accessToken = WeixinUtil.getAccessToken(); + AccessTokenView accessTokenView = new AccessTokenView(); + CloudCopyUtils.copyBean(accessToken,accessTokenView); + accessTokenView.setCreateTime(System.currentTimeMillis()); + accessTokenView.setUpdateTime(System.currentTimeMillis()); + accessTokenView.setWeight(System.currentTimeMillis()); + accessTokenView.setEnabled(ConsumeConstant.ENABLED); + accessTokenService.saveEntity(accessTokenView); + return accessToken.getAccessToken(); + } + // token存在判断是否过期 + AccessToken accessToken = accessTokenAll.get(0); + Long nowTime = System.currentTimeMillis(); + // 只获取一小时的 + Long expiresTime = accessToken.getUpdateTime() + (accessToken.getExpiresIn() * 1000) / 2; + // 已过期 重新获取token信息 + if (nowTime > expiresTime) { + AccessToken accessTokenUpdate = WeixinUtil.getAccessToken(); + AccessTokenView accessTokenView = new AccessTokenView(); + CloudCopyUtils.copyBean(accessToken,accessTokenView); + accessTokenView.setUpdateTime(System.currentTimeMillis()); + accessTokenView.setAccessToken(accessTokenUpdate.getAccessToken()); + accessTokenView.setExpiresIn(accessTokenUpdate.getExpiresIn()); + accessTokenService.updateEntity(accessTokenView); + return accessTokenView.getAccessToken(); + } + return accessToken.getAccessToken(); + } +} diff --git a/src/main/java/com/cloud/service/assets/AssetsService.java b/src/main/java/com/cloud/service/assets/AssetsService.java new file mode 100644 index 0000000000000000000000000000000000000000..8893d7a504774b343d20ed4329feaa9c45455b5c --- /dev/null +++ b/src/main/java/com/cloud/service/assets/AssetsService.java @@ -0,0 +1,29 @@ +package com.cloud.service.assets; + +import com.cloud.model.view.assets.AssetsView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* Assets +*

+* Assets的具体实现 +*

+* Creation Time: 2019-10-15 17:21:44. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface AssetsService extends BaseService { + + /** + * 通过用户id获取总消费情况信息 + * @return + */ + AssetsView getAssetsViewByUserId(Long userId); + +} diff --git a/src/main/java/com/cloud/service/assets/impl/AssetsServiceImpl.java b/src/main/java/com/cloud/service/assets/impl/AssetsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..6d5df579c662429bcd877721ade71e68d9677f1a --- /dev/null +++ b/src/main/java/com/cloud/service/assets/impl/AssetsServiceImpl.java @@ -0,0 +1,165 @@ +package com.cloud.service.assets.impl; + +import com.cloud.dao.assets.AssetsDao; +import com.cloud.dao.assetsdetail.AssetsDetailDao; +import com.cloud.model.entity.assets.Assets; +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.view.assets.AssetsView; +import com.cloud.model.view.assetsdetail.AssetsDetailView; +import com.cloud.service.assets.AssetsService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* AssetsImpl +*

+* Assets的具体实现 +*

+* Creation Time: 2019-10-15 17:21:44. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class AssetsServiceImpl implements AssetsService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(AssetsServiceImpl.class); + + @Autowired + private AssetsDao assetsDao; + + @Autowired + private AssetsDetailDao assetsDetailDao; + + @Override + public AssetsView getEntity(long id) { + // 获取Entity + Assets assets = assetsDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + AssetsView assetsView = new AssetsView(); + CloudCopyUtils.copyBean(assets, assetsView); + return assetsView; + } + + @Override + public long getEntitiesCount() { + return assetsDao.count(); + } + + @Override + public List findAll() { + List assetsViews = new ArrayList<>(); + List assetss = assetsDao.findAll(); + for (Assets assets : assetss){ + AssetsView assetsView = new AssetsView(); + CloudCopyUtils.copyBean(assets, assetsView); + assetsViews.add(assetsView); + } + return assetsViews; + } + + @Override + public AssetsView saveEntity(AssetsView assetsView) { + // 保存的业务逻辑 + Assets assets = new Assets(); + CloudCopyUtils.copyBean(assetsView, assets); + // user数据库映射传给dao进行存储 + assets.setCreateTime(System.currentTimeMillis()); + assets.setUpdateTime(System.currentTimeMillis()); + assets.setWeight(System.currentTimeMillis()); + assets.setEnabled(1); + assetsDao.save(assets); + CloudCopyUtils.copyBean(assets,assetsView); + return assetsView; + } + + @Override + public void deleteEntity(long id) { + Assets assets = assetsDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + assets.setId(id); + assetsDao.delete(assets); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List assetss = new ArrayList<>(); + for(String entityId : entityIds){ + Assets assets = new Assets(); + assets.setId(Long.valueOf(entityId)); + assetss.add(assets); + } + assetsDao.deleteInBatch(assetss); + } + + @Override + public void updateEntity(AssetsView assetsView) { + Specification assetsSpecification = Optional.ofNullable(assetsView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("AssetsView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional assetsOptionalBySearch = assetsDao.findOne(assetsSpecification); + assetsOptionalBySearch.map(assetsBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(assetsView,assetsBySearch); + assetsBySearch.setUpdateTime(System.currentTimeMillis()); + assetsDao.save(assetsBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + assetsView.getId() + "的数据记录")); + } + + @Override + public AssetsView getAssetsViewByUserId(Long userId) { + Assets assets = assetsDao.findByUserId(userId); + if (ObjectUtils.isEmpty(assets)) { + throw new RuntimeException("获取不到用户id:" + userId + "的统计数据,请重新登录"); + } + AssetsView assetsView = new AssetsView(); + CloudCopyUtils.copyBean(assets,assetsView); + // 获取每月详情信息 + List assetsDetails = assetsDetailDao.findByAssetsId(assets.getId()); + if (ObjectUtils.isEmpty(assetsDetails) || assetsDetails.size() == 0) { + return assetsView; + } + List assetsDetailViews = new ArrayList<>(); + for (AssetsDetail assetsDetail:assetsDetails) { + AssetsDetailView assetsDetailView = new AssetsDetailView(); + CloudCopyUtils.copyBean(assetsDetail,assetsDetailView); + assetsDetailViews.add(assetsDetailView); + } + assetsView.setAssetsDetailViews(assetsDetailViews); + return assetsView; + } +} diff --git a/src/main/java/com/cloud/service/assetsdetail/AssetsDetailService.java b/src/main/java/com/cloud/service/assetsdetail/AssetsDetailService.java new file mode 100644 index 0000000000000000000000000000000000000000..99f1e283ac36be422f4f852d9f21aeaef0861964 --- /dev/null +++ b/src/main/java/com/cloud/service/assetsdetail/AssetsDetailService.java @@ -0,0 +1,49 @@ +package com.cloud.service.assetsdetail; + +import com.cloud.model.view.assetsdetail.AssetsDetailView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* AssetsDetail +*

+* AssetsDetail的具体实现 +*

+* Creation Time: 2019-10-15 17:22:19. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface AssetsDetailService extends BaseService { + + /** + * 保存初始化统计表数据 + * @param userId + */ + void saveAssetsAndAssetsDetail(Long userId); + + /** + * 根据用户id和消费时间更新对应月份的统计和总消费 + * @param userId + * @param consumeTime + */ + void updateMonyByUserIdAndConsumeTime(Long userId, Long consumeTime); + + /** + * 根据用户id获取本月统计表 + * @param userId + * @return + */ + AssetsDetailView getEntityByUserId(Long userId); + + /** + * 通过用户id和时间获取指定月份每天消费情况信息 + */ + AssetsDetailView getAssetsDetailViewByValueMonthAndUserId(Long userId,Long valueTime); + + +} diff --git a/src/main/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImpl.java b/src/main/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..61ac7d6b3f3a85afd04e68ddadf5b038dec60847 --- /dev/null +++ b/src/main/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImpl.java @@ -0,0 +1,307 @@ +package com.cloud.service.assetsdetail.impl; + +import com.alibaba.fastjson.JSONObject; +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.dao.assetsdetail.AssetsDetailDao; +import com.cloud.model.entity.assets.Assets; +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.entity.consumetype.ConsumeType; +import com.cloud.model.view.assets.AssetsView; +import com.cloud.model.view.assetsdetail.AssetsDetailView; +import com.cloud.model.view.comsumepie.ComsumePieView; +import com.cloud.model.view.consumetype.ConsumeTypeView; +import com.cloud.service.assetsdetail.AssetsDetailService; +import com.cloud.commons.utils.CloudCopyUtils; +import com.cloud.service.assets.AssetsService; +import com.cloud.commons.utils.DateUtils; +import com.cloud.dao.bookkeeping.BookkeepingDao; +import com.cloud.dao.assets.AssetsDao; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * AssetsDetailImpl + *

+ * AssetsDetail的具体实现 + *

+ * Creation Time: 2019-10-15 17:22:19. + * + * @author ${model.author} + * @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public class AssetsDetailServiceImpl implements AssetsDetailService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(AssetsDetailServiceImpl.class); + + @Autowired + private AssetsDetailDao assetsDetailDao; + + @Autowired + private AssetsService assetsService; + + @Autowired + private BookkeepingDao bookkeepingDao; + + @Autowired + private AssetsDao assetsDao; + + @Autowired + private AssetsDetailService assetsDetailService; + + @Override + public AssetsDetailView getEntity(long id) { + // 获取Entity + AssetsDetail assetsDetail = assetsDetailDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + AssetsDetailView assetsDetailView = new AssetsDetailView(); + CloudCopyUtils.copyBean(assetsDetail, assetsDetailView); + return assetsDetailView; + } + + @Override + public long getEntitiesCount() { + return assetsDetailDao.count(); + } + + @Override + public List findAll() { + List assetsDetailViews = new ArrayList<>(); + List assetsDetails = assetsDetailDao.findAll(); + for (AssetsDetail assetsDetail : assetsDetails) { + AssetsDetailView assetsDetailView = new AssetsDetailView(); + CloudCopyUtils.copyBean(assetsDetail, assetsDetailView); + assetsDetailViews.add(assetsDetailView); + } + return assetsDetailViews; + } + + @Override + public AssetsDetailView saveEntity(AssetsDetailView assetsDetailView) { + // 保存的业务逻辑 + AssetsDetail assetsDetail = new AssetsDetail(); + CloudCopyUtils.copyBean(assetsDetailView, assetsDetail); + // user数据库映射传给dao进行存储 + assetsDetail.setCreateTime(System.currentTimeMillis()); + assetsDetail.setUpdateTime(System.currentTimeMillis()); + assetsDetail.setWeight(System.currentTimeMillis()); + assetsDetail.setEnabled(1); + assetsDetailDao.save(assetsDetail); + CloudCopyUtils.copyBean(assetsDetail, assetsDetailView); + return assetsDetailView; + } + + @Override + public void deleteEntity(long id) { + AssetsDetail assetsDetail = assetsDetailDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + assetsDetail.setId(id); + assetsDetailDao.delete(assetsDetail); + } + + @Override + @Transactional(rollbackOn = {Exception.class}) + public void deleteEntities(String ids) { + String[] entityIds = ids.split("\\,"); + List assetsDetails = new ArrayList<>(); + for (String entityId : entityIds) { + AssetsDetail assetsDetail = new AssetsDetail(); + assetsDetail.setId(Long.valueOf(entityId)); + assetsDetails.add(assetsDetail); + } + assetsDetailDao.deleteInBatch(assetsDetails); + } + + @Override + public void updateEntity(AssetsDetailView assetsDetailView) { + Specification assetsDetailSpecification = Optional.ofNullable(assetsDetailView).map(s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(() -> new IllegalArgumentException("AssetsDetailView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional assetsDetailOptionalBySearch = assetsDetailDao.findOne(assetsDetailSpecification); + assetsDetailOptionalBySearch.map(assetsDetailBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(assetsDetailView, assetsDetailBySearch); + assetsDetailBySearch.setUpdateTime(System.currentTimeMillis()); + assetsDetailDao.save(assetsDetailBySearch); + return ""; + }).orElseThrow(() -> new RuntimeException("无法找到id为" + assetsDetailView.getId() + "的数据记录")); + } + + @Override + @Transactional + public void saveAssetsAndAssetsDetail(Long userId) { + + Assets assets = assetsDao.findByUserId(userId); + AssetsView assetsView = new AssetsView(); + if (!ObjectUtils.isEmpty(assets)) { + // 存在则复制 + CloudCopyUtils.copyBean(assets, assetsView); + } else { + // 不存在新建数据 + assetsView = createAssetsView(userId); + } + + + Long monthFirstDay = DateUtils.getCurrentMonthFirstDay(System.currentTimeMillis()); + AssetsDetail assetsDetail = assetsDetailDao.findByAssetsIdAndNowFirstMonth(assetsView.getId(), monthFirstDay); + if (ObjectUtils.isEmpty(assetsDetail)) { + // 不存在新建数据 + createAssetsDetailView(assetsView.getId(), userId); + + } + + + } + + private void createAssetsDetailView(Long assetsId, Long userId) { + AssetsDetailView assetsDetailView = new AssetsDetailView(); + assetsDetailView.setAssetsId(assetsId); + assetsDetailView.setUserId(userId); + assetsDetailView.setMonthTotalExpenditure(ConsumeConstant.MONRY_INIT); + assetsDetailView.setMonthTotalMoney(ConsumeConstant.MONRY_INIT); + assetsDetailView.setMonthTotalIncome(ConsumeConstant.MONRY_INIT); + assetsDetailView.setNowMonth(DateUtils.getYearAndMonth(System.currentTimeMillis())); + assetsDetailView.setNowFirstMonth(DateUtils.getCurrentMonthFirstDay(System.currentTimeMillis())); + this.saveEntity(assetsDetailView); + } + + private AssetsView createAssetsView(Long userId) { + AssetsView assetsView = new AssetsView(); + assetsView.setUserId(userId); + assetsView.setTotalMoney(ConsumeConstant.MONRY_INIT); + assetsView.setTotalIncome(ConsumeConstant.MONRY_INIT); + assetsView.setTotalExpenditure(ConsumeConstant.MONRY_INIT); + assetsView = assetsService.saveEntity(assetsView); + return assetsView; + } + + @Override + @Transactional + public void updateMonyByUserIdAndConsumeTime(Long userId, Long consumeTime) { + Long startTime = DateUtils.getCurrentMonthFirstDay(consumeTime); + Long endTime = DateUtils.getCurrentMonthLastDay(consumeTime); + AssetsDetail assetsDetail = assetsDetailDao.findByUserIdAndNowFirstMonth(userId, startTime); + if (ObjectUtils.isEmpty(assetsDetail)) { + // 获取不到数据,重新新建数据信息 + this.saveAssetsAndAssetsDetail(userId); + assetsDetail = assetsDetailDao.findByUserIdAndNowFirstMonth(userId, startTime); + } + Map bookkeepingMap = bookkeepingDao.sunByUserIdAndConsumeTimeBetween(userId, startTime, endTime); + + Long income = !ObjectUtils.isEmpty(bookkeepingMap.get("income")) ? Long.valueOf(String.valueOf(bookkeepingMap.get("income"))) : 0L; + Long expenditure = !ObjectUtils.isEmpty(bookkeepingMap.get("expenditure")) ? Long.valueOf(String.valueOf(bookkeepingMap.get("expenditure"))) : 0L; + Long money = income - expenditure; + + // 更新月收入 + AssetsDetailView assetsDetailView = new AssetsDetailView(); + assetsDetailView.setMonthTotalIncome(income); + assetsDetailView.setMonthTotalExpenditure(expenditure); + assetsDetailView.setMonthTotalMoney(money); + assetsDetailView.setId(assetsDetail.getId()); + assetsDetailService.updateEntity(assetsDetailView); + + // 更新总收入 + Map assetsDetailMap = assetsDetailDao.sunMoneyByAssetsId(assetsDetail.getAssetsId()); + Long totalIncome = Long.valueOf(String.valueOf(assetsDetailMap.get("income"))); + Long totalExpenditure = Long.valueOf(String.valueOf(assetsDetailMap.get("expenditure"))); + Long totalMoney = Long.valueOf(String.valueOf(assetsDetailMap.get("money"))); + AssetsView assetsView = new AssetsView(); + assetsView.setId(assetsDetail.getAssetsId()); + assetsView.setTotalIncome(totalIncome); + assetsView.setTotalExpenditure(totalExpenditure); + assetsView.setTotalMoney(totalMoney); + assetsService.updateEntity(assetsView); + } + + @Override + public AssetsDetailView getEntityByUserId(Long userId) { + Long monthFirstDay = DateUtils.getCurrentMonthFirstDay(System.currentTimeMillis()); + AssetsDetail assetsDetail = assetsDetailDao.findByUserIdAndNowFirstMonth(userId, monthFirstDay); + if (ObjectUtils.isEmpty(assetsDetail)) { + throw new RuntimeException("出现并发,获取不到用户id:" + userId + "的数据信息"); + } + AssetsDetailView assetsDetailView = new AssetsDetailView(); + CloudCopyUtils.copyBean(assetsDetail, assetsDetailView); + return assetsDetailView; + } + + @Override + public AssetsDetailView getAssetsDetailViewByValueMonthAndUserId(Long userId, Long valueTime) { + // 获取指定时间当时的月份 + List nowTimesValue = DateUtils.getDayByValueMonth(valueTime); + // 获取这个月开始时间戳 + Long startTimeValue = nowTimesValue.get(0); + // 获取这个月结束时间戳 + Long endTimeValue = nowTimesValue.get(nowTimesValue.size() -1); + // 通过指定时间月初,用户id,指定时间月所有的天数查询指定月每天消费情况 + List> totalDay = assetsDetailDao.findByNowFirstMonthAndUserIdAndMonthValues(startTimeValue, userId, nowTimesValue); + // 横纵标表示数值 + List categories = new ArrayList<>(); + // 每天总消费数据 + List totalMoneys = new ArrayList<>(); + // 每天支出数据 + List pays = new ArrayList<>(); + // 每天收入数据 + List incomes = new ArrayList<>(); + for (int i = 0; i < nowTimesValue.size(); i++) { + Map objectMap = totalDay.get(i); + String categorie = String.valueOf(objectMap.get("categorie")); + Integer totalMoney = String.valueOf(objectMap.get("totalMoney")).equals("0") ? 0 : Integer.parseInt(objectMap.get("totalMoney") + "") / 100; + Integer pay = String.valueOf(objectMap.get("pay")).equals("0") ? 0 : Integer.parseInt(objectMap.get("pay") + "") / 100; + Integer income = String.valueOf(objectMap.get("income")).equals("0") ? 0 : Integer.parseInt(objectMap.get("income") + "") / 100; + categories.add(categorie); + totalMoneys.add(totalMoney); + pays.add(pay); + incomes.add(income); + } + // 获取这个月份的消费分类情况 + List consumeTypePay = bookkeepingDao.countMoneyByConsumeTimeAndUserId(userId,startTimeValue,endTimeValue,ConsumeConstant.PAY); + List consumeTypeInCome = bookkeepingDao.countMoneyByConsumeTimeAndUserId(userId,startTimeValue,endTimeValue,ConsumeConstant.INCOME); + AssetsDetailView assetsDetailView = new AssetsDetailView(); + assetsDetailView.setCategories(categories); + assetsDetailView.setIncomes(incomes); + assetsDetailView.setPays(pays); + assetsDetailView.setTotalMoneys(totalMoneys); + assetsDetailView.setConsumePayProportion(consumeTypePay); + assetsDetailView.setConsumeIncomeProportion(consumeTypeInCome); + // 获取当前用户有效的消费时间 + Long starTime = !ObjectUtils.isEmpty(bookkeepingDao.findOneByUserIdAndEnabledOrderByConsumeTimeAsc(userId,ConsumeConstant.ENABLED)) ? bookkeepingDao.findOneByUserIdAndEnabledOrderByConsumeTimeAsc(userId,ConsumeConstant.ENABLED) : System.currentTimeMillis() ; + String billStartTime = DateUtils.timeStamp2Date(String.valueOf(starTime),ConsumeConstant.DATE_TIME_FORMAT); + String billEndTime = DateUtils.timeStamp2Date(String.valueOf(System.currentTimeMillis()),ConsumeConstant.DATE_TIME_FORMAT); + + assetsDetailView.setBillStartTime(billStartTime); + assetsDetailView.setBillEndTime(billEndTime); + return assetsDetailView; + } +} diff --git a/src/main/java/com/cloud/service/base/BaseService.java b/src/main/java/com/cloud/service/base/BaseService.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca143f86da56589446423a16d4f55604360ec5b --- /dev/null +++ b/src/main/java/com/cloud/service/base/BaseService.java @@ -0,0 +1,58 @@ +package com.cloud.service.base; + +import java.util.List; + +/** + * 最基本的增删改查 + * @param + */ +public interface BaseService { + /** + * 保存 entity. + * + * @param entity the entity + * @return entity + */ + public T saveEntity(T entity); + + /** + * 删除 entity. + * + * @param id the id + */ + public void deleteEntity(long id); + + /** + * 批量删除 + */ + public void deleteEntities(String ids); + + + + /** + * 更新 entity. + * + * @param entity the entity + */ + public void updateEntity(T entity); + + /** + * 获取 entity. + * + * @param id the id + * @return entity the entity + */ + public T getEntity(long id); + + /** + * 统计 + */ + public long getEntitiesCount(); + + /** + * 查询全部 + */ + public List findAll(); + + +} diff --git a/src/main/java/com/cloud/service/bookkeeping/BookkeepingService.java b/src/main/java/com/cloud/service/bookkeeping/BookkeepingService.java new file mode 100644 index 0000000000000000000000000000000000000000..fc95c805986bed41926f3f7a24382d99769d537d --- /dev/null +++ b/src/main/java/com/cloud/service/bookkeeping/BookkeepingService.java @@ -0,0 +1,32 @@ +package com.cloud.service.bookkeeping; + +import com.cloud.model.view.bookkeeping.BookkeepingView; +import com.cloud.service.base.BaseService; +import org.springframework.data.domain.Page; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* Bookkeeping +*

+* Bookkeeping的具体实现 +*

+* Creation Time: 2019-10-15 17:24:19. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface BookkeepingService extends BaseService { + + Page getEntityPage(Long userId, Integer pageNumber, Integer pageSize); + + /** + * 保存记账信息 + * @param bookkeepingView + * @return + */ + BookkeepingView saveBookkeepingView(BookkeepingView bookkeepingView); +} diff --git a/src/main/java/com/cloud/service/bookkeeping/impl/BookkeepingServiceImpl.java b/src/main/java/com/cloud/service/bookkeeping/impl/BookkeepingServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..15cb195844fddbabb632b688f7ba603943c2d7a6 --- /dev/null +++ b/src/main/java/com/cloud/service/bookkeeping/impl/BookkeepingServiceImpl.java @@ -0,0 +1,257 @@ +package com.cloud.service.bookkeeping.impl; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.commons.utils.DateUtils; +import com.cloud.dao.bookkeeping.BookkeepingDao; +import com.cloud.dao.wxuser.WxUserDao; +import com.cloud.dao.wxusersubscribe.WxUserSubscribeDao; +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.entity.bookkeeping.Bookkeeping; +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import com.cloud.model.view.bookkeeping.BookkeepingView; +import com.cloud.service.bookkeeping.BookkeepingService; +import com.cloud.commons.utils.CloudCopyUtils; +import com.cloud.service.assetsdetail.AssetsDetailService; +import com.cloud.dao.assetsdetail.AssetsDetailDao; +import com.cloud.service.wxtemplatemessage.WxTemplateMessageService; +import com.cloud.thread.AssetsDetailThread; +import com.cloud.thread.WxTemplateMessageThread; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +/** +* BookkeepingImpl +*

+* Bookkeeping的具体实现 +*

+* Creation Time: 2019-10-15 17:24:19. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class BookkeepingServiceImpl implements BookkeepingService{ + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(BookkeepingServiceImpl.class); + + @Autowired + private BookkeepingDao bookkeepingDao; + + @Autowired + private AssetsDetailService assetsDetailService; + + @Autowired + private WxUserDao wxUserDao; + + @Autowired + private AssetsDetailDao assetsDetailDao; + + @Autowired + WxTemplateMessageService wxTemplateMessageService; + + @Autowired + private WxUserSubscribeDao wxUserSubscribeDao; + + @Override + public BookkeepingView getEntity(long id) { + // 获取Entity + Bookkeeping bookkeeping = bookkeepingDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + BookkeepingView bookkeepingView = new BookkeepingView(); + CloudCopyUtils.copyBean(bookkeeping, bookkeepingView); + return bookkeepingView; + } + + @Override + public long getEntitiesCount() { + return bookkeepingDao.count(); + } + + @Override + public List findAll() { + List bookkeepingViews = new ArrayList<>(); + List bookkeepings = bookkeepingDao.findAll(); + for (Bookkeeping bookkeeping : bookkeepings){ + BookkeepingView bookkeepingView = new BookkeepingView(); + CloudCopyUtils.copyBean(bookkeeping, bookkeepingView); + bookkeepingViews.add(bookkeepingView); + } + return bookkeepingViews; + } + + @Override + public BookkeepingView saveEntity(BookkeepingView bookkeepingView) { + // 保存的业务逻辑 + Bookkeeping bookkeeping = new Bookkeeping(); + CloudCopyUtils.copyBean(bookkeepingView, bookkeeping); + // user数据库映射传给dao进行存储 + bookkeeping.setCreateTime(System.currentTimeMillis()); + bookkeeping.setUpdateTime(System.currentTimeMillis()); + bookkeeping.setWeight(System.currentTimeMillis()); + bookkeeping.setConsumeTime(System.currentTimeMillis()); + bookkeeping.setConsumeTimeDay(DateUtils.getDayStartTime(System.currentTimeMillis())); + bookkeeping.setIsShowTime(ConsumeConstant.ENABLED); + if (ObjectUtils.isEmpty(bookkeeping.getRemarks())) { + bookkeeping.setRemarks(ConsumeConstant.REMART); + } + bookkeeping.setEnabled(1); + bookkeepingDao.save(bookkeeping); + CloudCopyUtils.copyBean(bookkeeping,bookkeepingView); + return bookkeepingView; + } + + @Override + @Transactional + public void deleteEntity(long id) { + Bookkeeping bookkeeping = bookkeepingDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + bookkeeping.setId(id); + bookkeepingDao.delete(bookkeeping); + // 判断is_show是否为1,1 :将最近一条数据修改为1 + existsIsShowTime(bookkeeping); + + // 更新数据信息 + assetsDetailService.updateMonyByUserIdAndConsumeTime(bookkeeping.getUserId(),bookkeeping.getConsumeTime()); + } + + /** + * 判断is_show是否为1,1 :将最近一条数据修改为1 + * @param bookkeeping + */ + private void existsIsShowTime(Bookkeeping bookkeeping) { + if (bookkeeping.getIsShowTime().equals(ConsumeConstant.ENABLED)) { + Long startTime = DateUtils.getDayStartTime(bookkeeping.getConsumeTime()); + Long endTime = DateUtils.getDayEndTime(bookkeeping.getConsumeTime()); + List bookkeepings = bookkeepingDao.findByUserIdAndIsShowTimeAndConsumeTimeBetweenOrderByWeightDesc(bookkeeping.getUserId(),ConsumeConstant.DISABLED,startTime,endTime); + if (ObjectUtils.isEmpty(bookkeepings) || bookkeepings.size() == 0) { + return; + } + bookkeepingDao.updateIsShowTimeById(ConsumeConstant.ENABLED,System.currentTimeMillis(),bookkeepings.get(0).getId()); + } + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List bookkeepings = new ArrayList<>(); + for(String entityId : entityIds){ + Bookkeeping bookkeeping = new Bookkeeping(); + bookkeeping.setId(Long.valueOf(entityId)); + bookkeepings.add(bookkeeping); + } + bookkeepingDao.deleteInBatch(bookkeepings); + } + + @Override + public void updateEntity(BookkeepingView bookkeepingView) { + Specification bookkeepingSpecification = Optional.ofNullable(bookkeepingView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("BookkeepingView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional bookkeepingOptionalBySearch = bookkeepingDao.findOne(bookkeepingSpecification); + bookkeepingOptionalBySearch.map(bookkeepingBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(bookkeepingView,bookkeepingBySearch); + bookkeepingBySearch.setUpdateTime(System.currentTimeMillis()); + bookkeepingDao.save(bookkeepingBySearch); + // 更新统计表数据信息 + assetsDetailService.updateMonyByUserIdAndConsumeTime(bookkeepingBySearch.getUserId(),bookkeepingBySearch.getConsumeTime()); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + bookkeepingView.getId() + "的数据记录")); + } + + @Override + public Page getEntityPage(Long userId, Integer pageNumber, Integer pageSize) { + Pageable pageable = PageRequest.of(pageNumber,pageSize); + Page bookkeepingPage= bookkeepingDao.findAllByUserIdAndEnabledOrderByConsumeTimeDesc(userId, ConsumeConstant.ENABLED,pageable); + return bookkeepingPage.map(bookkeeping -> { + BookkeepingView bookkeepingView = new BookkeepingView(); + CloudCopyUtils.copyBean(bookkeeping,bookkeepingView); + // 统计当天总消费与日期 + this.countTotalMomeyAndNowDayTime(bookkeepingView); + return bookkeepingView; + }); + } + + @Override + @Transactional + public BookkeepingView saveBookkeepingView(BookkeepingView bookkeepingView) { + // 吧当天的相关记账数据isShowTime更新为0 + this.updateIsShowTime(bookkeepingView.getUserId()); + // 保存记账信息 + bookkeepingView = this.saveEntity(bookkeepingView); + // 更新本月统计表信息 (用多线程进行更新) + assetsDetailService.updateMonyByUserIdAndConsumeTime(bookkeepingView.getUserId(),bookkeepingView.getConsumeTime()); +// AssetsDetailThread assetsDetailThread = new AssetsDetailThread(bookkeepingView.getUserId(),bookkeepingView.getConsumeTime()); +// assetsDetailThread.start(); + try { + // 校验本月是否超出,发送模板消息 (用多线程进行发送) + WxTemplateMessageThread wxTemplateMessageThread = new WxTemplateMessageThread(bookkeepingView); + wxTemplateMessageThread.start(); + } catch (Exception e) { + // 纯记录,不需要抛出 + LOG.error("发送模板消息异常:" + e.getMessage()); + } finally { + System.out.println("主线程 - 保存记账表成功"); + return bookkeepingView; + } + } + private void updateIsShowTime(Long userId) { + Long currentStartTime = DateUtils.getCurrentDayStartTime(); + Long currentEndTime = DateUtils.getCurrentDayEndTime(); + bookkeepingDao.updateIsShowTimeByUserIdAndIsShowTimeAndConsumeTimeBetween(System.currentTimeMillis(),userId,ConsumeConstant.ENABLED,currentStartTime,currentEndTime); + } + + private void countTotalMomeyAndNowDayTime(BookkeepingView bookkeepingView) { + if (bookkeepingView.getIsShowTime().intValue() == 0) { + return; + } + Long dayStartTime = DateUtils.getDayStartTime(bookkeepingView.getConsumeTime()); + Long dayEndTime = DateUtils.getDayEndTime(bookkeepingView.getConsumeTime()); + Long userId = bookkeepingView.getUserId(); + String formatConsumeTime = DateUtils.timeStamp2Date(String.valueOf(bookkeepingView.getConsumeTime()),ConsumeConstant.DATE_FORMAT); + String formatConsumeTimeDay = DateUtils.getWeekOfDate(new Date(bookkeepingView.getConsumeTime())); + Integer totalMoney = bookkeepingDao.sunByEnabledAndUserIdAndConsumeTimeBetween(ConsumeConstant.ENABLED,userId,dayStartTime,dayEndTime); + bookkeepingView.setTotalMoney(totalMoney); + bookkeepingView.setNowDayTime(formatConsumeTime + " " + formatConsumeTimeDay); + } + +// public static void main(String[] args) { +// AssetsDetailThread assetsDetailThread = new AssetsDetailThread(); +// assetsDetailThread.start(); +// AssetsDetailThread assetsDetailThread1 = new AssetsDetailThread(); +// assetsDetailThread1.start(); +// } +} diff --git a/src/main/java/com/cloud/service/city/CityService.java b/src/main/java/com/cloud/service/city/CityService.java new file mode 100644 index 0000000000000000000000000000000000000000..524aa515fcabea76d9fc72098b3d346d65e608ce --- /dev/null +++ b/src/main/java/com/cloud/service/city/CityService.java @@ -0,0 +1,23 @@ +package com.cloud.service.city; + +import com.cloud.model.view.city.CityView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* City +*

+* City的具体实现 +*

+* Creation Time: 2019-10-16 14:30:33. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface CityService extends BaseService { + +} diff --git a/src/main/java/com/cloud/service/city/impl/CityServiceImpl.java b/src/main/java/com/cloud/service/city/impl/CityServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..02b077b9d7812db0f03c8ba2469653aa002cef69 --- /dev/null +++ b/src/main/java/com/cloud/service/city/impl/CityServiceImpl.java @@ -0,0 +1,135 @@ +package com.cloud.service.city.impl; + +import com.cloud.dao.city.CityDao; +import com.cloud.model.entity.city.City; +import com.cloud.model.view.city.CityView; +import com.cloud.service.city.CityService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* CityImpl +*

+* City的具体实现 +*

+* Creation Time: 2019-10-16 14:30:33. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class CityServiceImpl implements CityService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(CityServiceImpl.class); + + @Autowired + private CityDao cityDao; + + @Override + public CityView getEntity(long id) { + // 获取Entity + City city = cityDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + CityView cityView = new CityView(); + CloudCopyUtils.copyBean(city, cityView); + return cityView; + } + + @Override + public long getEntitiesCount() { + return cityDao.count(); + } + + @Override + public List findAll() { + List cityViews = new ArrayList<>(); + List citys = cityDao.findAll(); + for (City city : citys){ + CityView cityView = new CityView(); + CloudCopyUtils.copyBean(city, cityView); + cityViews.add(cityView); + } + return cityViews; + } + + @Override + public CityView saveEntity(CityView cityView) { + // 保存的业务逻辑 + City city = new City(); + CloudCopyUtils.copyBean(cityView, city); + // user数据库映射传给dao进行存储 + city.setCreateTime(System.currentTimeMillis()); + city.setUpdateTime(System.currentTimeMillis()); + city.setWeight(System.currentTimeMillis()); + city.setEnabled(1); + cityDao.save(city); + CloudCopyUtils.copyBean(city,cityView); + return cityView; + } + + @Override + public void deleteEntity(long id) { + City city = cityDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + city.setId(id); + cityDao.delete(city); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List citys = new ArrayList<>(); + for(String entityId : entityIds){ + City city = new City(); + city.setId(Long.valueOf(entityId)); + citys.add(city); + } + cityDao.deleteInBatch(citys); + } + + @Override + public void updateEntity(CityView cityView) { + Specification citySpecification = Optional.ofNullable(cityView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("CityView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional cityOptionalBySearch = cityDao.findOne(citySpecification); + cityOptionalBySearch.map(cityBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(cityView,cityBySearch); + cityBySearch.setUpdateTime(System.currentTimeMillis()); + cityDao.save(cityBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + cityView.getId() + "的数据记录")); + } +} diff --git a/src/main/java/com/cloud/service/cityweather/CityWeatherService.java b/src/main/java/com/cloud/service/cityweather/CityWeatherService.java new file mode 100644 index 0000000000000000000000000000000000000000..1491958ec11130a1dc6b348ac4f60841e2726e33 --- /dev/null +++ b/src/main/java/com/cloud/service/cityweather/CityWeatherService.java @@ -0,0 +1,29 @@ +package com.cloud.service.cityweather; + +import com.cloud.model.entity.city.City; +import com.cloud.model.view.cityweather.CityWeatherView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* CityWeather +*

+* CityWeather的具体实现 +*

+* Creation Time: 2019-10-16 14:31:05. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface CityWeatherService extends BaseService { + + /** + * 更新或保存对应的城市表天气信息 + * @param city + */ + void updateCityWeatherEntiy(City city); +} diff --git a/src/main/java/com/cloud/service/cityweather/impl/CityWeatherServiceImpl.java b/src/main/java/com/cloud/service/cityweather/impl/CityWeatherServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9cf2f58952e91b485c201621c30918139d3a00c5 --- /dev/null +++ b/src/main/java/com/cloud/service/cityweather/impl/CityWeatherServiceImpl.java @@ -0,0 +1,182 @@ +package com.cloud.service.cityweather.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.cloud.commons.utils.weather.WeatherUtil; +import com.cloud.dao.cityweather.CityWeatherDao; +import com.cloud.model.entity.city.City; +import com.cloud.model.entity.cityweather.CityWeather; +import com.cloud.model.view.cityweather.CityWeatherView; +import com.cloud.scheduled.WeatherScheduled; +import com.cloud.service.cityweather.CityWeatherService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* CityWeatherImpl +*

+* CityWeather的具体实现 +*

+* Creation Time: 2019-10-16 14:31:05. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class CityWeatherServiceImpl implements CityWeatherService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(CityWeatherServiceImpl.class); + + @Autowired + private CityWeatherDao cityWeatherDao; + + @Override + public CityWeatherView getEntity(long id) { + // 获取Entity + CityWeather cityWeather = cityWeatherDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + CityWeatherView cityWeatherView = new CityWeatherView(); + CloudCopyUtils.copyBean(cityWeather, cityWeatherView); + return cityWeatherView; + } + + @Override + public long getEntitiesCount() { + return cityWeatherDao.count(); + } + + @Override + public List findAll() { + List cityWeatherViews = new ArrayList<>(); + List cityWeathers = cityWeatherDao.findAll(); + for (CityWeather cityWeather : cityWeathers){ + CityWeatherView cityWeatherView = new CityWeatherView(); + CloudCopyUtils.copyBean(cityWeather, cityWeatherView); + cityWeatherViews.add(cityWeatherView); + } + return cityWeatherViews; + } + + @Override + public CityWeatherView saveEntity(CityWeatherView cityWeatherView) { + // 保存的业务逻辑 + CityWeather cityWeather = new CityWeather(); + CloudCopyUtils.copyBean(cityWeatherView, cityWeather); + // user数据库映射传给dao进行存储 + cityWeather.setCreateTime(System.currentTimeMillis()); + cityWeather.setUpdateTime(System.currentTimeMillis()); + cityWeather.setWeight(System.currentTimeMillis()); + cityWeather.setEnabled(1); + cityWeatherDao.save(cityWeather); + CloudCopyUtils.copyBean(cityWeather,cityWeatherView); + return cityWeatherView; + } + + @Override + public void deleteEntity(long id) { + CityWeather cityWeather = cityWeatherDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + cityWeather.setId(id); + cityWeatherDao.delete(cityWeather); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List cityWeathers = new ArrayList<>(); + for(String entityId : entityIds){ + CityWeather cityWeather = new CityWeather(); + cityWeather.setId(Long.valueOf(entityId)); + cityWeathers.add(cityWeather); + } + cityWeatherDao.deleteInBatch(cityWeathers); + } + + @Override + public void updateEntity(CityWeatherView cityWeatherView) { + Specification cityWeatherSpecification = Optional.ofNullable(cityWeatherView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("CityWeatherView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional cityWeatherOptionalBySearch = cityWeatherDao.findOne(cityWeatherSpecification); + cityWeatherOptionalBySearch.map(cityWeatherBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(cityWeatherView,cityWeatherBySearch); + cityWeatherBySearch.setUpdateTime(System.currentTimeMillis()); + cityWeatherDao.save(cityWeatherBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + cityWeatherView.getId() + "的数据记录")); + } + + @Override + @Transactional + public void updateCityWeatherEntiy(City city) { + // 目前先获取两种类型的信息,当前天气情况和未来三天天气情况 + String location = ""; + String weatherTypeNow = "now"; + location += !ObjectUtils.isEmpty(city.getArea()) ? city.getArea() + "," + city.getCity() : city.getCity(); + // 保存当前天气情况 + saveOrupdateWeatherView(city, location, weatherTypeNow); + // 保存未来三天天气情况 + String weatherTypeForecast = "forecast"; + saveOrupdateWeatherView(city,location,weatherTypeForecast); + } + + private void saveOrupdateWeatherView(City city, String location, String weatherTypeNow) { + JSONObject weatherResultJson = WeatherUtil.getHeweatherResult(weatherTypeNow,location); + CityWeather cityWeather = cityWeatherDao.findByCityIdAndWeatherType(city.getId(),weatherTypeNow); + if (ObjectUtils.isEmpty(cityWeather)) { + // 新建信息 + createCityWeatherView(city.getId(),weatherResultJson,weatherTypeNow); + } else { + // 更新信息 + updateCityWeatherView(cityWeather,weatherResultJson); + } + } + + private void updateCityWeatherView(CityWeather cityWeather, JSONObject weatherResultJson) { + CityWeatherView cityWeatherView = new CityWeatherView(); + CloudCopyUtils.copyBean(cityWeather,cityWeatherView); + cityWeatherView.setWeatherResultJson(JSON.toJSONString(weatherResultJson)); + updateEntity(cityWeatherView); + } + + private void createCityWeatherView(Long cityId, JSONObject weatherResultJson, String weatherTypeNow) { + CityWeatherView cityWeatherView = new CityWeatherView(); + cityWeatherView.setCityId(cityId); + cityWeatherView.setWeatherResultJson(JSON.toJSONString(weatherResultJson)); + cityWeatherView.setWeatherType(weatherTypeNow); + saveEntity(cityWeatherView); + } +} diff --git a/src/main/java/com/cloud/service/consumetype/ConsumeTypeService.java b/src/main/java/com/cloud/service/consumetype/ConsumeTypeService.java new file mode 100644 index 0000000000000000000000000000000000000000..c94c68da1d97832f00b76f25ae25bac76453e88e --- /dev/null +++ b/src/main/java/com/cloud/service/consumetype/ConsumeTypeService.java @@ -0,0 +1,24 @@ +package com.cloud.service.consumetype; + +import com.cloud.model.view.consumetype.ConsumeTypeView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* ConsumeType +*

+* ConsumeType的具体实现 +*

+* Creation Time: 2019-10-15 17:23:42. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface ConsumeTypeService extends BaseService { + + List getAllEntityByType(Integer type); +} diff --git a/src/main/java/com/cloud/service/consumetype/impl/ConsumeTypeServiceImpl.java b/src/main/java/com/cloud/service/consumetype/impl/ConsumeTypeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..1940faee31894b0701c63f73c9a1c0a021459779 --- /dev/null +++ b/src/main/java/com/cloud/service/consumetype/impl/ConsumeTypeServiceImpl.java @@ -0,0 +1,152 @@ +package com.cloud.service.consumetype.impl; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.dao.consumetype.ConsumeTypeDao; +import com.cloud.model.entity.consumetype.ConsumeType; +import com.cloud.model.view.consumetype.ConsumeTypeView; +import com.cloud.service.consumetype.ConsumeTypeService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* ConsumeTypeImpl +*

+* ConsumeType的具体实现 +*

+* Creation Time: 2019-10-15 17:23:42. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class ConsumeTypeServiceImpl implements ConsumeTypeService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(ConsumeTypeServiceImpl.class); + + @Autowired + private ConsumeTypeDao consumeTypeDao; + + @Override + public ConsumeTypeView getEntity(long id) { + // 获取Entity + ConsumeType consumeType = consumeTypeDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + ConsumeTypeView consumeTypeView = new ConsumeTypeView(); + CloudCopyUtils.copyBean(consumeType, consumeTypeView); + return consumeTypeView; + } + + @Override + public long getEntitiesCount() { + return consumeTypeDao.count(); + } + + @Override + public List findAll() { + List consumeTypeViews = new ArrayList<>(); + List consumeTypes = consumeTypeDao.findAll(); + for (ConsumeType consumeType : consumeTypes){ + ConsumeTypeView consumeTypeView = new ConsumeTypeView(); + CloudCopyUtils.copyBean(consumeType, consumeTypeView); + consumeTypeViews.add(consumeTypeView); + } + return consumeTypeViews; + } + + @Override + public ConsumeTypeView saveEntity(ConsumeTypeView consumeTypeView) { + // 保存的业务逻辑 + ConsumeType consumeType = new ConsumeType(); + CloudCopyUtils.copyBean(consumeTypeView, consumeType); + // user数据库映射传给dao进行存储 + consumeType.setCreateTime(System.currentTimeMillis()); + consumeType.setUpdateTime(System.currentTimeMillis()); + consumeType.setWeight(System.currentTimeMillis()); + consumeType.setEnabled(1); + consumeTypeDao.save(consumeType); + CloudCopyUtils.copyBean(consumeType,consumeTypeView); + return consumeTypeView; + } + + @Override + public void deleteEntity(long id) { + ConsumeType consumeType = consumeTypeDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到id为:" + id + "的数据记录")); + consumeType.setId(id); + consumeTypeDao.delete(consumeType); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List consumeTypes = new ArrayList<>(); + for(String entityId : entityIds){ + ConsumeType consumeType = new ConsumeType(); + consumeType.setId(Long.valueOf(entityId)); + consumeTypes.add(consumeType); + } + consumeTypeDao.deleteInBatch(consumeTypes); + } + + @Override + public void updateEntity(ConsumeTypeView consumeTypeView) { + Specification consumeTypeSpecification = Optional.ofNullable(consumeTypeView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("ConsumeTypeView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional consumeTypeOptionalBySearch = consumeTypeDao.findOne(consumeTypeSpecification); + consumeTypeOptionalBySearch.map(consumeTypeBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(consumeTypeView,consumeTypeBySearch); + consumeTypeBySearch.setUpdateTime(System.currentTimeMillis()); + consumeTypeDao.save(consumeTypeBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + consumeTypeView.getId() + "的数据记录")); + } + + @Override + public List getAllEntityByType(Integer type) { + List consumeTypes = consumeTypeDao.findAllByEnabledAndTypeOrderByWeightDesc(ConsumeConstant.ENABLED,type); + List consumeTypeViews = new ArrayList<>(); + if (ObjectUtils.isEmpty(consumeTypes) || consumeTypes.size() == 0) { + return consumeTypeViews; + } + for (ConsumeType consumeType:consumeTypes) { + ConsumeTypeView consumeTypeView = new ConsumeTypeView(); + CloudCopyUtils.copyBean(consumeType,consumeTypeView); + consumeTypeViews.add(consumeTypeView); + } + return consumeTypeViews; + } +} diff --git a/src/main/java/com/cloud/service/wxsubscribe/WxSubscribeService.java b/src/main/java/com/cloud/service/wxsubscribe/WxSubscribeService.java new file mode 100644 index 0000000000000000000000000000000000000000..6ccf8e71df38c501d929f7b5d03f0fe5bd00a5c8 --- /dev/null +++ b/src/main/java/com/cloud/service/wxsubscribe/WxSubscribeService.java @@ -0,0 +1,23 @@ +package com.cloud.service.wxsubscribe; + +import com.cloud.model.view.wxsubscribe.WxSubscribeView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* WxSubscribe +*

+* WxSubscribe的具体实现 +*

+* Creation Time: 2020-01-11 17:45:41. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface WxSubscribeService extends BaseService { + +} diff --git a/src/main/java/com/cloud/service/wxsubscribe/impl/WxSubscribeServiceImpl.java b/src/main/java/com/cloud/service/wxsubscribe/impl/WxSubscribeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a20b8452b856507facc0d31e07451c814ab3110a --- /dev/null +++ b/src/main/java/com/cloud/service/wxsubscribe/impl/WxSubscribeServiceImpl.java @@ -0,0 +1,134 @@ +package com.cloud.service.wxsubscribe.impl; + +import com.cloud.dao.wxsubscribe.WxSubscribeDao; +import com.cloud.model.entity.wxsubscribe.WxSubscribe; +import com.cloud.model.view.wxsubscribe.WxSubscribeView; +import com.cloud.service.wxsubscribe.WxSubscribeService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* WxSubscribeImpl +*

+* WxSubscribe的具体实现 +*

+* Creation Time: 2020-01-11 17:45:41. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class WxSubscribeServiceImpl implements WxSubscribeService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(WxSubscribeServiceImpl.class); + + @Autowired + private WxSubscribeDao wxSubscribeDao; + + @Override + public WxSubscribeView getEntity(long id) { + // 获取Entity + WxSubscribe wxSubscribe = wxSubscribeDao.getOne(id); + // 复制Dao层属性到view属性 + WxSubscribeView wxSubscribeView = new WxSubscribeView(); + CloudCopyUtils.copyBean(wxSubscribe, wxSubscribeView); + return wxSubscribeView; + } + + @Override + public long getEntitiesCount() { + return wxSubscribeDao.count(); + } + + @Override + public List findAll() { + List wxSubscribeViews = new ArrayList<>(); + List wxSubscribes = wxSubscribeDao.findAll(); + for (WxSubscribe wxSubscribe : wxSubscribes){ + WxSubscribeView wxSubscribeView = new WxSubscribeView(); + CloudCopyUtils.copyBean(wxSubscribe, wxSubscribeView); + wxSubscribeViews.add(wxSubscribeView); + } + return wxSubscribeViews; + } + + @Override + public WxSubscribeView saveEntity(WxSubscribeView wxSubscribeView) { + // 保存的业务逻辑 + WxSubscribe wxSubscribe = new WxSubscribe(); + CloudCopyUtils.copyBean(wxSubscribeView, wxSubscribe); + // user数据库映射传给dao进行存储 + wxSubscribe.setCreateTime(System.currentTimeMillis()); + wxSubscribe.setUpdateTime(System.currentTimeMillis()); + wxSubscribe.setEnabled(1); + wxSubscribeDao.save(wxSubscribe); + CloudCopyUtils.copyBean(wxSubscribe,wxSubscribeView); + return wxSubscribeView; + } + + @Override + public void deleteEntity(long id) { + WxSubscribe wxSubscribe = new WxSubscribe(); + wxSubscribe.setId(id); + wxSubscribeDao.delete(wxSubscribe); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List wxSubscribes = new ArrayList<>(); + for(String entityId : entityIds){ + WxSubscribe wxSubscribe = new WxSubscribe(); + wxSubscribe.setId(Long.valueOf(entityId)); + wxSubscribes.add(wxSubscribe); + } + wxSubscribeDao.deleteInBatch(wxSubscribes); + } + + @Override + public void updateEntity(WxSubscribeView wxSubscribeView) { + Specification wxSubscribeSpecification = Optional.ofNullable(wxSubscribeView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("WxSubscribeView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional wxSubscribeOptionalBySearch = wxSubscribeDao.findOne(wxSubscribeSpecification); + wxSubscribeOptionalBySearch.map(wxSubscribeBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(wxSubscribeView,wxSubscribeBySearch); + wxSubscribeBySearch.setUpdateTime(System.currentTimeMillis()); + wxSubscribeDao.save(wxSubscribeBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + wxSubscribeView.getId() + "的数据记录")); + } +} diff --git a/src/main/java/com/cloud/service/wxtemplatemessage/WxTemplateMessageService.java b/src/main/java/com/cloud/service/wxtemplatemessage/WxTemplateMessageService.java new file mode 100644 index 0000000000000000000000000000000000000000..ed77aff4767464aaf0bfc07656a3f0de39e1c065 --- /dev/null +++ b/src/main/java/com/cloud/service/wxtemplatemessage/WxTemplateMessageService.java @@ -0,0 +1,25 @@ +package com.cloud.service.wxtemplatemessage; + +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.view.bookkeeping.BookkeepingView; + +/** + * 微信模板消息提醒 + */ +public interface WxTemplateMessageService { + /** + * 消费成功通知 + * @param bookkeepingView + * @param wxUser + * @throws Exception + */ + public void bookkeepingSuccessMessage(BookkeepingView bookkeepingView, WxUser wxUser); + + /** + * 消费预算通知 + * @param bookkeepingView + * @param wxUser + * @param monthTotalExpenditure + */ + void accountingBudgetMessage(BookkeepingView bookkeepingView, WxUser wxUser, Long monthTotalExpenditure); +} diff --git a/src/main/java/com/cloud/service/wxtemplatemessage/impl/WxTemplateMessageSerivceImpl.java b/src/main/java/com/cloud/service/wxtemplatemessage/impl/WxTemplateMessageSerivceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f1c900d21a5d5c53e9aac165c0baf05fee05df1c --- /dev/null +++ b/src/main/java/com/cloud/service/wxtemplatemessage/impl/WxTemplateMessageSerivceImpl.java @@ -0,0 +1,145 @@ +package com.cloud.service.wxtemplatemessage.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.commons.utils.DateUtils; +import com.cloud.commons.utils.wechat.WeixinUtil; +import com.cloud.dao.consumetype.ConsumeTypeDao; +import com.cloud.dao.wxuser.WxUserDao; +import com.cloud.model.entity.consumetype.ConsumeType; +import com.cloud.model.entity.wxmintemplateproject.WxMinTemplateProject; +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.view.bookkeeping.BookkeepingView; +import com.cloud.service.accesstoken.AccessTokenService; +import com.cloud.service.wxtemplatemessage.WxTemplateMessageService; +import org.apache.catalina.User; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +@Service +public class WxTemplateMessageSerivceImpl implements WxTemplateMessageService { + + private static final Logger LOG = LoggerFactory.getLogger(WxTemplateMessageSerivceImpl.class); + + @Autowired + private WxUserDao wxUserDao; + + @Autowired + private AccessTokenService accessTokenService; + + @Autowired + private ConsumeTypeDao consumeTypeDao; + + @Override + public void bookkeepingSuccessMessage(BookkeepingView bookkeepingView, WxUser wxUser){ + // 订阅id + String templateId = "nlD1JNUEtWlHjUiqcNFOYJQBG-akvOSbST0b0aWllOs"; + // 校验必填参数是否完善 + if (ObjectUtils.isEmpty(wxUser.getId())) { + throw new RuntimeException("模板消息发送失败,必填参数缺少"); + } + // userId + Long userId = wxUser.getId(); + // 设置跳转页面 + String page = "pages/index/authoriztion/authoriztion?form=bookkeepingDetail&bookkeepingid=" + bookkeepingView.getId(); + // 设置模板消息内容 + List keywordValues = new ArrayList<>(); + // 记账时间 + String nowTime = DateUtils.timeStamp2Date(String.valueOf(bookkeepingView.getConsumeTime()), ConsumeConstant.DATE_FORMAT); + keywordValues.add(nowTime); + // 记账类型 + ConsumeType consumeType = consumeTypeDao.findById(bookkeepingView.getConsumeTypeId()).orElseThrow(() -> new RuntimeException("获取不到记账类型id为:" + bookkeepingView.getConsumeTypeId() + "的数据信息")); + String orderType = consumeType.getName(); + keywordValues.add(orderType); + // 金额 + String money = String.valueOf(bookkeepingView.getMoney() / 100) + "元"; + keywordValues.add(money); + // 记账人 + String bookkeepingBeople = wxUser.getNickName(); + keywordValues.add(bookkeepingBeople); + // 消费详情 + String consumeDetail = "您在" + bookkeepingView.getAddress() + "花费了" + bookkeepingView.getMoney() /100+ "元"; + keywordValues.add(consumeDetail); + + // 进行发送模板消息 + sendTemplateMessage(templateId, userId, page, keywordValues); + } + + @Override + public void accountingBudgetMessage(BookkeepingView bookkeepingView, WxUser wxUser, Long monthTotalExpenditure) { + // 订阅id + String templateId = "9idG4F8CNOaiGOo5EYwqB4wxVx8QXtoSg1HjNMnlM4M"; + // 校验必填参数是否完善 + if (ObjectUtils.isEmpty(wxUser.getId())) { + throw new RuntimeException("模板消息发送失败,必填参数缺少"); + } + // userId + Long userId = wxUser.getId(); + // 设置跳转页面 + String page = "pages/index/authoriztion/authoriztion?form=me&userId=" + userId; + // 设置模板消息内容 + List keywordValues = new ArrayList<>(); + // 记账时间 + String nowTime = DateUtils.timeStamp2Date(String.valueOf(bookkeepingView.getConsumeTime()), ConsumeConstant.DATE_FORMAT); + keywordValues.add(nowTime); + // 记账类型 + keywordValues.add("月预算"); + // 剩余预算金额 + String money = (wxUser.getMonthBudget().intValue() - monthTotalExpenditure.intValue()) / 100 + "元"; + keywordValues.add(money); + // 温馨提示 + String tips = ""; + if (wxUser.getMonthBudget().intValue() - monthTotalExpenditure.intValue() > 0) { + tips = "您的预算即将耗尽,请注意合理消费"; + } else { + tips = "您的预算已耗尽,请注意合理消费"; + } + + keywordValues.add(tips); + + // 进行发送模板消息 + sendTemplateMessage(templateId, userId, page, keywordValues); + + } + + private JSONObject sendTemplateMessage(String templateId, Long userId, String page, List keywordValues){ + // accesstoken + String accessToken = accessTokenService.getAccessToken(); + // 设置openid + Optional wxUserOptional = wxUserDao.findById(userId); + WxUser wxUser = wxUserOptional.orElseThrow(() -> new RuntimeException("模板消息发送失败 获取不到用户id为" + userId + "的数据")); + String openId = wxUser.getOpenId(); + + JSONObject jsonObjectResult = null; + try { + // 进行封装 + WxMinTemplateProject wxMinTemplateProject = new WxMinTemplateProject(templateId,openId,page,keywordValues); + + // 获取模板消息所需要的id + JSONObject resultTemplateProject = WeixinUtil.setMiniProgramTemplateData(wxMinTemplateProject); + + // 请求回来的数据信息 + String resultData = WeixinUtil.sendMiniProgramTemplate(accessToken, resultTemplateProject); + + LOG.info("这个是请求订阅消息回来的数据信息:" + JSON.toJSONString(resultData)); + + jsonObjectResult = JSON.parseObject(resultData); + + if (jsonObjectResult.getString("errcode").equals("0")) { + LOG.info("模板消息发送成功啦!!发送的对象openId是:" + openId); + } + } catch (Exception e) { + LOG.error("模板消息发送失败!!!" + e.getMessage()); + } + + return jsonObjectResult; + } +} diff --git a/src/main/java/com/cloud/service/wxuser/WxUserService.java b/src/main/java/com/cloud/service/wxuser/WxUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..0ff608f9b9415432b68d6c941a1706664d2f7594 --- /dev/null +++ b/src/main/java/com/cloud/service/wxuser/WxUserService.java @@ -0,0 +1,29 @@ +package com.cloud.service.wxuser; + +import com.cloud.model.view.wxuser.WxUserView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* WxUser +*

+* WxUser的具体实现 +*

+* Creation Time: 2019-10-15 16:15:58. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface WxUserService extends BaseService { + + /** + * t + * @param code + * @return + */ + WxUserView checkUserLogin(String code); +} diff --git a/src/main/java/com/cloud/service/wxuser/impl/WxUserServiceImpl.java b/src/main/java/com/cloud/service/wxuser/impl/WxUserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7ee9375908c0abbd8b7f387edc43c62e60cc206d --- /dev/null +++ b/src/main/java/com/cloud/service/wxuser/impl/WxUserServiceImpl.java @@ -0,0 +1,201 @@ +package com.cloud.service.wxuser.impl; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.commons.utils.wechat.WeixinUtil; +import com.cloud.dao.wxuser.WxUserDao; +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.view.wxuser.WxUserView; +import com.cloud.service.wxuser.WxUserService; +import com.cloud.commons.utils.CloudCopyUtils; +import com.cloud.commons.utils.JwtUtils; +import com.cloud.service.assetsdetail.AssetsDetailService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* WxUserImpl +*

+* WxUser的具体实现 +*

+* Creation Time: 2019-10-15 16:15:58. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class WxUserServiceImpl implements WxUserService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(WxUserServiceImpl.class); + + @Autowired + private WxUserDao wxUserDao; + + @Value("${server.port}") + private String port; + + @Value("${file.sonPath}") + private String sonPath; + + + @Autowired + private AssetsDetailService assetsDetailService; + + @Override + public WxUserView getEntity(long id) { + // 获取Entity + WxUser wxUser = wxUserDao.findById(id).orElseThrow(() -> new RuntimeException("获取不到用户id为:" + id + "的数据记录")); + // 复制Dao层属性到view属性 + WxUserView wxUserView = new WxUserView(); + CloudCopyUtils.copyBean(wxUser, wxUserView); + return wxUserView; + } + + @Override + public long getEntitiesCount() { + return wxUserDao.count(); + } + + @Override + public List findAll() { + List wxUserViews = new ArrayList<>(); + List wxUsers = wxUserDao.findAll(); + for (WxUser wxUser : wxUsers){ + WxUserView wxUserView = new WxUserView(); + CloudCopyUtils.copyBean(wxUser, wxUserView); + wxUserViews.add(wxUserView); + } + return wxUserViews; + } + + @Override + public WxUserView saveEntity(WxUserView wxUserView) { + // 保存的业务逻辑 + WxUser wxUser = new WxUser(); + CloudCopyUtils.copyBean(wxUserView, wxUser); + // user数据库映射传给dao进行存储 + wxUser.setCreateTime(System.currentTimeMillis()); + wxUser.setUpdateTime(System.currentTimeMillis()); + wxUser.setWeight(System.currentTimeMillis()); + wxUser.setMonthBudget(5000L); + wxUser.setSendMessage(ConsumeConstant.DISABLED); + wxUser.setEnabled(ConsumeConstant.ENABLED); + wxUserDao.save(wxUser); + CloudCopyUtils.copyBean(wxUser,wxUserView); + return wxUserView; + } + + @Override + public void deleteEntity(long id) { + WxUser wxUser = wxUserDao.findById(id).orElseThrow(() ->new RuntimeException("用户id为:" + id + "的数据已被删除")); + wxUser.setId(id); + wxUserDao.delete(wxUser); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List wxUsers = new ArrayList<>(); + for(String entityId : entityIds){ + WxUser wxUser = new WxUser(); + wxUser.setId(Long.valueOf(entityId)); + wxUsers.add(wxUser); + } + wxUserDao.deleteInBatch(wxUsers); + } + + @Override + public void updateEntity(WxUserView wxUserView) { + Specification wxUserSpecification = Optional.ofNullable(wxUserView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("WxUserView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional wxUserOptionalBySearch = wxUserDao.findOne(wxUserSpecification); + wxUserOptionalBySearch.map(wxUserBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(wxUserView,wxUserBySearch); + wxUserBySearch.setUpdateTime(System.currentTimeMillis()); + wxUserDao.save(wxUserBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + wxUserView.getId() + "的数据记录")); + } + + @Override + @Transactional + public WxUserView checkUserLogin(String code) { + if (ObjectUtils.isEmpty(code)) { + throw new NullPointerException("code不合法"); + } + // 进行访问 + String openId = WeixinUtil.code2Session(code); + // 判断openId是否存在 + WxUser wxUser = wxUserDao.findByOpenId(openId); + if (!ObjectUtils.isEmpty(wxUser)) { + WxUserView wxUserView = new WxUserView(); + wxUser.setLoginEndTime(System.currentTimeMillis()); + BeanUtils.copyProperties(wxUser,wxUserView); + //携带token信息 + wxUserView.setToken(JwtUtils.getToken()); + // 存在记录最后登录时间然后直接返回数据 + updateEntity(wxUserView); + // 判断当月统计表是否新建 + assetsDetailService.saveAssetsAndAssetsDetail(wxUserView.getId()); + return wxUserView; + } else { + // 新建用户信息 + return createWxUserView(openId); + } + } + + /** + * 创建用户基本信息 + * @return + */ + private WxUserView createWxUserView(String openId) { + WxUserView wxUserView = new WxUserView(); + // 不存在新建用户信息 + wxUserView.setOpenId(openId); + // 默认图片信息 + String avatarUrl = "https://be.yangyoki.top:" + port + sonPath + "avatar/avatar.png"; + String nickName = "点击头像获取微信头像、昵称"; + wxUserView.setAvatarUrl(avatarUrl); + wxUserView.setNickName(nickName); + wxUserView.setMonthBudget(ConsumeConstant.MONRY_INIT); + wxUserView.setLoginEndTime(System.currentTimeMillis()); + WxUserView wxUserViewResult = saveEntity(wxUserView); + // 新建统计表数据 + assetsDetailService.saveAssetsAndAssetsDetail(wxUserViewResult.getId()); + return wxUserViewResult; + } +} diff --git a/src/main/java/com/cloud/service/wxusersubscribe/WxUserSubscribeService.java b/src/main/java/com/cloud/service/wxusersubscribe/WxUserSubscribeService.java new file mode 100644 index 0000000000000000000000000000000000000000..b59f8a2d6a7d6d158ec92a679736bc8358368e4a --- /dev/null +++ b/src/main/java/com/cloud/service/wxusersubscribe/WxUserSubscribeService.java @@ -0,0 +1,23 @@ +package com.cloud.service.wxusersubscribe; + +import com.cloud.model.view.wxusersubscribe.WxUserSubscribeView; +import com.cloud.service.base.BaseService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* WxUserSubscribe +*

+* WxUserSubscribe的具体实现 +*

+* Creation Time: 2020-01-12 00:22:03. +* +* @author ${model.author} +* @version 1.0.0 + * @since cloud-spring-boot-be 1.0.0 + */ +@Service +public interface WxUserSubscribeService extends BaseService { + +} diff --git a/src/main/java/com/cloud/service/wxusersubscribe/impl/WxUserSubscribeServiceImpl.java b/src/main/java/com/cloud/service/wxusersubscribe/impl/WxUserSubscribeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f2afdee335c33770cd362f8bb52f1a94651d0d70 --- /dev/null +++ b/src/main/java/com/cloud/service/wxusersubscribe/impl/WxUserSubscribeServiceImpl.java @@ -0,0 +1,143 @@ +package com.cloud.service.wxusersubscribe.impl; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.dao.wxusersubscribe.WxUserSubscribeDao; +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import com.cloud.model.view.wxusersubscribe.WxUserSubscribeView; +import com.cloud.service.wxusersubscribe.WxUserSubscribeService; +import com.cloud.commons.utils.CloudCopyUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.*; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** +* WxUserSubscribeImpl +*

+* WxUserSubscribe的具体实现 +*

+* Creation Time: 2020-01-12 00:22:03. +* +* @author ${model.author} +* @version 1.0.0 +* @since cloud-spring-boot-be 1.0.0 +*/ +@Service +public class WxUserSubscribeServiceImpl implements WxUserSubscribeService { + + /** + * The Constant LOG. + */ + private static final Logger LOG = LoggerFactory + .getLogger(WxUserSubscribeServiceImpl.class); + + @Autowired + private WxUserSubscribeDao wxUserSubscribeDao; + + @Override + public WxUserSubscribeView getEntity(long id) { + // 获取Entity + WxUserSubscribe wxUserSubscribe = wxUserSubscribeDao.getOne(id); + // 复制Dao层属性到view属性 + WxUserSubscribeView wxUserSubscribeView = new WxUserSubscribeView(); + CloudCopyUtils.copyBean(wxUserSubscribe, wxUserSubscribeView); + return wxUserSubscribeView; + } + + @Override + public long getEntitiesCount() { + return wxUserSubscribeDao.count(); + } + + @Override + public List findAll() { + List wxUserSubscribeViews = new ArrayList<>(); + List wxUserSubscribes = wxUserSubscribeDao.findAll(); + for (WxUserSubscribe wxUserSubscribe : wxUserSubscribes){ + WxUserSubscribeView wxUserSubscribeView = new WxUserSubscribeView(); + CloudCopyUtils.copyBean(wxUserSubscribe, wxUserSubscribeView); + wxUserSubscribeViews.add(wxUserSubscribeView); + } + return wxUserSubscribeViews; + } + + @Override + public WxUserSubscribeView saveEntity(WxUserSubscribeView wxUserSubscribeView) { + if (ObjectUtils.isEmpty(wxUserSubscribeView.getSubscribeId()) || ObjectUtils.isEmpty(wxUserSubscribeView.getUserId())) { + throw new RuntimeException("缺少参数信息,无法进行保存"); + } + // 保存的业务逻辑 + WxUserSubscribe wxUserSubscribe = wxUserSubscribeDao.findByUserIdAndSubscribeId(wxUserSubscribeView.getUserId(),wxUserSubscribeView.getSubscribeId()); + if (ObjectUtils.isEmpty(wxUserSubscribe)) { + wxUserSubscribe = new WxUserSubscribe(); + wxUserSubscribe.setCreateTime(System.currentTimeMillis()); + wxUserSubscribe.setEnabled(ConsumeConstant.ENABLED); + } + CloudCopyUtils.copyBeanExcludeNull(wxUserSubscribeView, wxUserSubscribe); + // user数据库映射传给dao进行存储 + wxUserSubscribe.setUpdateTime(System.currentTimeMillis()); + wxUserSubscribe.setWeight(System.currentTimeMillis()); + wxUserSubscribeDao.save(wxUserSubscribe); + CloudCopyUtils.copyBean(wxUserSubscribe,wxUserSubscribeView); + return wxUserSubscribeView; + } + + @Override + public void deleteEntity(long id) { + WxUserSubscribe wxUserSubscribe = new WxUserSubscribe(); + wxUserSubscribe.setId(id); + wxUserSubscribeDao.delete(wxUserSubscribe); + } + + @Override + @Transactional(rollbackOn = { Exception.class }) + public void deleteEntities(String ids) { + String[] entityIds= ids.split("\\,"); + List wxUserSubscribes = new ArrayList<>(); + for(String entityId : entityIds){ + WxUserSubscribe wxUserSubscribe = new WxUserSubscribe(); + wxUserSubscribe.setId(Long.valueOf(entityId)); + wxUserSubscribes.add(wxUserSubscribe); + } + wxUserSubscribeDao.deleteInBatch(wxUserSubscribes); + } + + @Override + public void updateEntity(WxUserSubscribeView wxUserSubscribeView) { + Specification wxUserSubscribeSpecification = Optional.ofNullable(wxUserSubscribeView).map( s -> { + return new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List predicates = new ArrayList<>(); + // id + predicates.add(criteriaBuilder.equal(root.get("id").as(Long.class), s.getId())); + + criteriaQuery.where(predicates.toArray(new Predicate[predicates.size()])); + return criteriaQuery.getRestriction(); + } + }; + }).orElseThrow(()->new IllegalArgumentException("WxUserSubscribeView is null")); + + + // 获取原有的属性,把不变的属性覆盖 + Optional wxUserSubscribeOptionalBySearch = wxUserSubscribeDao.findOne(wxUserSubscribeSpecification); + wxUserSubscribeOptionalBySearch.map(wxUserSubscribeBySearch -> { + CloudCopyUtils.copyBeanExcludeNull(wxUserSubscribeView,wxUserSubscribeBySearch); + wxUserSubscribeBySearch.setUpdateTime(System.currentTimeMillis()); + wxUserSubscribeDao.save(wxUserSubscribeBySearch); + return ""; + }).orElseThrow(()->new RuntimeException("无法找到id为" + wxUserSubscribeView.getId() + "的数据记录")); + } +} diff --git a/src/main/java/com/cloud/thread/AssetsDetailThread.java b/src/main/java/com/cloud/thread/AssetsDetailThread.java new file mode 100644 index 0000000000000000000000000000000000000000..8c5126050818dfb8988101b1a12958d8b182b163 --- /dev/null +++ b/src/main/java/com/cloud/thread/AssetsDetailThread.java @@ -0,0 +1,160 @@ +package com.cloud.thread; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.commons.utils.CloudCopyUtils; +import com.cloud.commons.utils.DateUtils; +import com.cloud.dao.assets.AssetsDao; +import com.cloud.dao.assetsdetail.AssetsDetailDao; +import com.cloud.dao.bookkeeping.BookkeepingDao; +import com.cloud.dao.wxuser.WxUserDao; +import com.cloud.dao.wxusersubscribe.WxUserSubscribeDao; +import com.cloud.model.entity.assets.Assets; +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import com.cloud.model.view.assets.AssetsView; +import com.cloud.model.view.assetsdetail.AssetsDetailView; +import com.cloud.model.view.bookkeeping.BookkeepingView; +import com.cloud.service.assets.AssetsService; +import com.cloud.service.assetsdetail.AssetsDetailService; +import com.cloud.service.wxtemplatemessage.WxTemplateMessageService; +import com.mysql.cj.util.TestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; + +import javax.annotation.PostConstruct; +import java.util.Map; + +/** + * 子线程 - 负责统计总消费记录,月消费记录 + */ +@Component +public class AssetsDetailThread extends Thread { + + + private Long userId; + + private Long consumeTime; + + + public static AssetsDetailThread assetsDetailThread; + + @Autowired + private AssetsDetailDao assetsDetailDao; + + @Autowired + private AssetsDetailService assetsDetailService; + + @Autowired + private BookkeepingDao bookkeepingDao; + + @Autowired + private AssetsService assetsService; + + @Autowired + private AssetsDao assetsDao; + + /** + * 普通类调用bean 方法初始化 + */ + @PostConstruct + public void init() { + assetsDetailThread = this; + assetsDetailThread.assetsDetailDao = this.assetsDetailDao; + assetsDetailThread.bookkeepingDao = this.bookkeepingDao; + assetsDetailThread.assetsDetailService = this.assetsDetailService; + assetsDetailThread.assetsService = this.assetsService; + assetsDetailThread.assetsDao = this.assetsDao; + + } + + public AssetsDetailThread(Long userId,Long consumeTime) { + this.userId = userId; + this.consumeTime = consumeTime; + } + + public AssetsDetailThread() {} + public void run() { +// System.out.println("我这边调用了多线程负责统计总消费记录,月消费记录接口"); + Long startTime = DateUtils.getCurrentMonthFirstDay(consumeTime); + Long endTime = DateUtils.getCurrentMonthLastDay(consumeTime); + AssetsDetail assetsDetail = assetsDetailThread.assetsDetailDao.findByUserIdAndNowFirstMonth(userId, startTime); + if (ObjectUtils.isEmpty(assetsDetail)) { + // 获取不到数据,重新新建数据信息 + this.saveAssetsAndAssetsDetail(userId); + assetsDetail = assetsDetailThread.assetsDetailDao.findByUserIdAndNowFirstMonth(userId, startTime); + } + Map bookkeepingMap = assetsDetailThread.bookkeepingDao.sunByUserIdAndConsumeTimeBetween(userId, startTime, endTime); + + Long income = !ObjectUtils.isEmpty(bookkeepingMap.get("income")) ? Long.valueOf(String.valueOf(bookkeepingMap.get("income"))) : 0L; + Long expenditure = !ObjectUtils.isEmpty(bookkeepingMap.get("expenditure")) ? Long.valueOf(String.valueOf(bookkeepingMap.get("expenditure"))) : 0L; + Long money = income - expenditure; + + // 更新月收入 + AssetsDetailView assetsDetailView = new AssetsDetailView(); + assetsDetailView.setMonthTotalIncome(income); + assetsDetailView.setMonthTotalExpenditure(expenditure); + assetsDetailView.setMonthTotalMoney(money); + assetsDetailView.setId(assetsDetail.getId()); + assetsDetailThread.assetsDetailService.updateEntity(assetsDetailView); + + // 更新总收入 + Map assetsDetailMap = assetsDetailThread.assetsDetailDao.sunMoneyByAssetsId(assetsDetail.getAssetsId()); + Long totalIncome = Long.valueOf(String.valueOf(assetsDetailMap.get("income"))); + Long totalExpenditure = Long.valueOf(String.valueOf(assetsDetailMap.get("expenditure"))); + Long totalMoney = Long.valueOf(String.valueOf(assetsDetailMap.get("money"))); + AssetsView assetsView = new AssetsView(); + assetsView.setId(assetsDetail.getAssetsId()); + assetsView.setTotalIncome(totalIncome); + assetsView.setTotalExpenditure(totalExpenditure); + assetsView.setTotalMoney(totalMoney); + assetsDetailThread.assetsService.updateEntity(assetsView); + +// System.out.println("子线程 - 统计消费记录数据结束"); + } + + private void saveAssetsAndAssetsDetail(Long userId) { + Assets assets = assetsDetailThread.assetsDao.findByUserId(userId); + AssetsView assetsView = new AssetsView(); + if (!ObjectUtils.isEmpty(assets)) { + // 存在则复制 + CloudCopyUtils.copyBean(assets, assetsView); + } else { + // 不存在新建数据 + assetsView = createAssetsView(userId); + } + + + Long monthFirstDay = DateUtils.getCurrentMonthFirstDay(System.currentTimeMillis()); + AssetsDetail assetsDetail = assetsDetailDao.findByAssetsIdAndNowFirstMonth(assetsView.getId(), monthFirstDay); + if (ObjectUtils.isEmpty(assetsDetail)) { + // 不存在新建数据 + createAssetsDetailView(assetsView.getId(), userId); + + } + } + + private AssetsView createAssetsView(Long userId) { + AssetsView assetsView = new AssetsView(); + assetsView.setUserId(userId); + assetsView.setTotalMoney(ConsumeConstant.MONRY_INIT); + assetsView.setTotalIncome(ConsumeConstant.MONRY_INIT); + assetsView.setTotalExpenditure(ConsumeConstant.MONRY_INIT); + assetsView = assetsDetailThread.assetsService.saveEntity(assetsView); + return assetsView; + } + + + private void createAssetsDetailView(Long assetsId, Long userId) { + AssetsDetailView assetsDetailView = new AssetsDetailView(); + assetsDetailView.setAssetsId(assetsId); + assetsDetailView.setUserId(userId); + assetsDetailView.setMonthTotalExpenditure(ConsumeConstant.MONRY_INIT); + assetsDetailView.setMonthTotalMoney(ConsumeConstant.MONRY_INIT); + assetsDetailView.setMonthTotalIncome(ConsumeConstant.MONRY_INIT); + assetsDetailView.setNowMonth(DateUtils.getYearAndMonth(System.currentTimeMillis())); + assetsDetailView.setNowFirstMonth(DateUtils.getCurrentMonthFirstDay(System.currentTimeMillis())); + assetsDetailThread.assetsDetailService.saveEntity(assetsDetailView); + } +} diff --git a/src/main/java/com/cloud/thread/WxTemplateMessageThread.java b/src/main/java/com/cloud/thread/WxTemplateMessageThread.java new file mode 100644 index 0000000000000000000000000000000000000000..9ae3d028adf576f057d3aff37ba62572eedee896 --- /dev/null +++ b/src/main/java/com/cloud/thread/WxTemplateMessageThread.java @@ -0,0 +1,91 @@ +package com.cloud.thread; + +import com.cloud.commons.constants.ConsumeConstant; +import com.cloud.commons.utils.DateUtils; +import com.cloud.dao.assetsdetail.AssetsDetailDao; +import com.cloud.dao.wxuser.WxUserDao; +import com.cloud.dao.wxusersubscribe.WxUserSubscribeDao; +import com.cloud.model.entity.assetsdetail.AssetsDetail; +import com.cloud.model.entity.wxuser.WxUser; +import com.cloud.model.entity.wxusersubscribe.WxUserSubscribe; +import com.cloud.model.view.bookkeeping.BookkeepingView; +import com.cloud.service.wxtemplatemessage.WxTemplateMessageService; +import com.mysql.cj.util.TestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; + +import javax.annotation.PostConstruct; + +/** + * 子线程 - 负责发送模板消息 + */ +@Component +public class WxTemplateMessageThread extends Thread { + + private Logger LOG = LoggerFactory.getLogger(WxTemplateMessageThread.class); + + private BookkeepingView bookkeepingView; + + public static WxTemplateMessageThread wxTemplateMessageThread; + + @Autowired + private WxUserDao wxUserDao; + + @Autowired + private AssetsDetailDao assetsDetailDao; + + @Autowired + private WxUserSubscribeDao wxUserSubscribeDao; + + @Autowired + private WxTemplateMessageService wxTemplateMessageService; + + /** + * 普通类调用bean 方法初始化 + */ + @PostConstruct + public void init() { + wxTemplateMessageThread = this; + wxTemplateMessageThread.wxUserDao = this.wxUserDao; + wxTemplateMessageThread.assetsDetailDao = this.assetsDetailDao; + wxTemplateMessageThread.wxUserSubscribeDao = this.wxUserSubscribeDao; + wxTemplateMessageThread.wxTemplateMessageService = this.wxTemplateMessageService; + + } + + + + + public WxTemplateMessageThread(BookkeepingView bookkeepingView) { + this.bookkeepingView = bookkeepingView; + } + + public WxTemplateMessageThread() {} + public void run() { + LOG.info("我这边调用了多线程发送模板消息接口"); + Long userId = bookkeepingView.getUserId(); + WxUser wxUser = wxTemplateMessageThread.wxUserDao.findById(userId).orElseThrow(() -> new RuntimeException("获取不到用户信息 id是:" + userId)); + // 获取当月时间点 + Long monthFirst = DateUtils.getCurrentMonthFirstDay(bookkeepingView.getConsumeTime()); + AssetsDetail assetsDetail = wxTemplateMessageThread.assetsDetailDao.findByEnabledAndUserIdAndNowFirstMonth(ConsumeConstant.ENABLED,userId,monthFirst); + if (ObjectUtils.isEmpty(assetsDetail) || wxUser.getSendMessage().equals(ConsumeConstant.DISABLED)) { + return; + } + WxUserSubscribe bookkeepingSuccess = wxTemplateMessageThread.wxUserSubscribeDao.findByUserIdAndSubscribeId(userId,ConsumeConstant.BOOKKEEPING_SUCCESS); + // 发送消费成功模板消息 + if (!ObjectUtils.isEmpty(bookkeepingSuccess) && bookkeepingSuccess.getType().intValue() == ConsumeConstant.SUBSCRIBE_SUCCESS) { + wxTemplateMessageThread.wxTemplateMessageService.bookkeepingSuccessMessage(bookkeepingView,wxUser); + } + // 发送记账预算模板消息 + WxUserSubscribe accountingBudget = wxTemplateMessageThread.wxUserSubscribeDao.findByUserIdAndSubscribeId(userId,ConsumeConstant.ACCOUNTING_BUDGET); + // 是否超过本身百分之80 + Boolean isBoolean = wxUser.getMonthBudget().intValue() - assetsDetail.getMonthTotalExpenditure().intValue() < wxUser.getMonthBudget() * 0.2; + if (!ObjectUtils.isEmpty(accountingBudget) && isBoolean && accountingBudget.getType().intValue() == ConsumeConstant.SUBSCRIBE_SUCCESS) { + wxTemplateMessageThread.wxTemplateMessageService.accountingBudgetMessage(bookkeepingView,wxUser,assetsDetail.getMonthTotalExpenditure()); + } + LOG.info("子线程 - 发送模板消息请求结束"); + } +} diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 0000000000000000000000000000000000000000..bb92fd8cb1160d93bced9a165828b2eca72d4576 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,40 @@ +server.port=12000 + +##jdbc mysql 8.1ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://47.93.196.206:3306/consume-dev +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=root +spring.datasource.password=123456 +#spring.jpa.show-sql=true + +#ַ +spring.web.googleexcute=explorer +#Ҫ򿪵ַ +spring.web.loginurl=https://localhost:${server.port}/swagger-ui.html +#ǷҪʱ +spring.web.isopenurl=true + +logging.config=classpath:log/dev/logback.xml + +# ̬ԴⱩ¶· +file.staticAccessPath=/images/consume/** +#windowsµ· +#file.rootPath=E: +#Linuxµ· +file.rootPath=/root + +file.sonPath=/images/consume/ +#aopע +spring.aop.proxy-target-class=true +#tokenܳ +token.secret=consume +#СappId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 +#ͷkey +weather.key=a6f1b37a9c6c40fdb762df3fd50c4079 +#ɵ֤ +server.ssl.key-store=/root/ssl/be.yangyoki.top.pfx +server.ssl.key-store-password=v9Q8z58R +server.ssl.keyStoreType=PKCS12 \ No newline at end of file diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties new file mode 100644 index 0000000000000000000000000000000000000000..9f7014d9e34add58878c9a0b926648aa46cdb447 --- /dev/null +++ b/src/main/resources/application-local.properties @@ -0,0 +1,38 @@ +server.port=9066 + +##jdbc mysql 8.1ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://47.93.196.206:3306/consume-van +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=btn +spring.datasource.password=btn + + +#ַ +spring.web.googleexcute=explorer +#Ҫ򿪵ַ +spring.web.loginurl=https://localhost:${server.port}/swagger-ui.html +#ǷҪʱ +spring.web.isopenurl=false + +logging.config=classpath:log/local/logback.xml + +# ̬ԴⱩ¶· +file.staticAccessPath=/images/consume/** +#windowsµ· +#file.rootPath=E: +#Linuxµ· +file.rootPath=/root + +file.sonPath=/images/consume/ +#aopע +spring.aop.proxy-target-class=true +#tokenܳ +token.secret=consume +#СappId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 +#ɵ֤ +server.ssl.key-store=/root/ssl/be.yangyoki.top.pfx +server.ssl.key-store-password=v9Q8z58R +server.ssl.keyStoreType=PKCS12 \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties new file mode 100644 index 0000000000000000000000000000000000000000..07f5329bada2bfae5ab0f44769c31b470c346e1d --- /dev/null +++ b/src/main/resources/application-prod.properties @@ -0,0 +1,38 @@ +server.port=12000 + +##jdbc mysql 8.1ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://119.23.217.75:3306/consume-prod +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=root +spring.datasource.password=123456 + + +#ַ +spring.web.googleexcute=explorer +#Ҫ򿪵ַ +spring.web.loginurl=https://localhost:${server.port}/swagger-ui.html +#ǷҪʱ +spring.web.isopenurl=false + +logging.config=classpath:log/prod/logback.xml + +# ̬ԴⱩ¶· +#file.staticAccessPath=/images/consume/** +#windowsµ· +#file.rootPath=E: +#Linuxµ· +file.rootPath=/root/yyq + +file.sonPath=/images/consume/ +#aopע +spring.aop.proxy-target-class=true +#tokenܳ +token.secret=consume +#СappId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 +#ɵ֤ +server.ssl.key-store=/root/yyq/ssl/be.yangyoki.top.pfx +server.ssl.key-store-password=v9Q8z58R +server.ssl.keyStoreType=PKCS12 \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..a015c6821d62d6d69e4f201b01a42ffcc662e984 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.profiles.active=prod \ No newline at end of file diff --git a/src/main/resources/log/dev/logback.xml b/src/main/resources/log/dev/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..47d9977b2601d03ff7101867aab00b4322fd6cb0 --- /dev/null +++ b/src/main/resources/log/dev/logback.xml @@ -0,0 +1,38 @@ + + + + + /root/log/consume/dev/cloud.log + + /root/log/consume/dev/consume.%d{yyyy-MM-dd}.%i.log.zip + + 30 + + 10GB + + + 2MB + + + + %date %level [%thread] %logger{10} [%file:%line] %msg%n + UTF-8 + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/src/main/resources/log/local/logback.xml b/src/main/resources/log/local/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..bd3ff6b32cb5cb062e7d734795f2bae356d2cb1c --- /dev/null +++ b/src/main/resources/log/local/logback.xml @@ -0,0 +1,38 @@ + + + + + /root/log/consume/local/cloud.log + + /root/log/consume/local/consume.%d{yyyy-MM-dd}.%i.log.zip + + 30 + + 10GB + + + 2MB + + + + %date %level [%thread] %logger{10} [%file:%line] %msg%n + UTF-8 + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/src/main/resources/log/prod/logback.xml b/src/main/resources/log/prod/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..35e834c4c86a09ee6f7374b53f31ca65d2ce2246 --- /dev/null +++ b/src/main/resources/log/prod/logback.xml @@ -0,0 +1,38 @@ + + + + + /root/yyq/log/consume/prod/consume.log + + /root/yyq/log/consume/prod/consume.%d{yyyy-MM-dd}.%i.log.zip + + 30 + + 10GB + + + 2MB + + + + %date %level [%thread] %logger{10} [%file:%line] %msg%n + UTF-8 + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/src/test/java/com/cloud/commons/utils/weather/WeatherUtilTest.java b/src/test/java/com/cloud/commons/utils/weather/WeatherUtilTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9f037bb911ac9428e83e70d8e32a45c83b8edfce --- /dev/null +++ b/src/test/java/com/cloud/commons/utils/weather/WeatherUtilTest.java @@ -0,0 +1,17 @@ +package com.cloud.commons.utils.weather; + +import com.alibaba.fastjson.JSONObject; +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.Assert.*; + +@SpringBootTest +public class WeatherUtilTest { + + @Test + public void getHeweatherResult() { + JSONObject jsonObject = WeatherUtil.getHeweatherResult("now","guangzhou"); + System.out.println(jsonObject); + } +} \ No newline at end of file diff --git a/src/test/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImplTest.java b/src/test/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6119f351f1f97cf09d5515faac349432876aed0e --- /dev/null +++ b/src/test/java/com/cloud/service/assetsdetail/impl/AssetsDetailServiceImplTest.java @@ -0,0 +1,20 @@ +package com.cloud.service.assetsdetail.impl; + +import com.cloud.service.assetsdetail.AssetsDetailService; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.Assert.*; + +@SpringBootTest +public class AssetsDetailServiceImplTest { + + @Autowired + private AssetsDetailService assetsDetailService; + + @Test + public void getAssetsDetailViewByValueMonthAndUserId() { + System.out.println("哈哈"); + } +} \ No newline at end of file diff --git a/src/test/java/com/consume/commons/utils/wechat/AccessToeknUtilsTest.java b/src/test/java/com/consume/commons/utils/wechat/AccessToeknUtilsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6df2e58d8708f4ea3689c2fd69d641e323e90130 --- /dev/null +++ b/src/test/java/com/consume/commons/utils/wechat/AccessToeknUtilsTest.java @@ -0,0 +1,15 @@ +package com.consume.commons.utils.wechat; + +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.Assert.*; + +@SpringBootTest +public class AccessToeknUtilsTest { + @Test + public void getAccessToken() { +// AccessToken accessToken = WeixinUtil.getAccessToken(); +// System.out.println(accessToken.getAccessToken()); + } +} \ No newline at end of file diff --git a/target/classes/META-INF/consume-be.kotlin_module b/target/classes/META-INF/consume-be.kotlin_module new file mode 100644 index 0000000000000000000000000000000000000000..8fb60192d378759239a3ecbf60eac8c8de446e9c Binary files /dev/null and b/target/classes/META-INF/consume-be.kotlin_module differ diff --git a/target/classes/application-dev.properties b/target/classes/application-dev.properties new file mode 100644 index 0000000000000000000000000000000000000000..3d34094b1e229fce5c2e8879d434f9932b9af575 --- /dev/null +++ b/target/classes/application-dev.properties @@ -0,0 +1,38 @@ +server.port=12000 + +##jdbc���� mysql 8.1���ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://47.93.196.206:3306/consume-van +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=root +spring.datasource.password=123456 +#spring.jpa.show-sql=true + +#�����������ַ +spring.web.googleexcute=explorer +#Ҫ�򿪵���ַ +spring.web.loginurl=https://localhost:${server.port}/swagger-ui.html +#�Ƿ�Ҫ����ʱ������� +spring.web.isopenurl=true + +#logging.config=classpath:log/dev/logback.xml + +# ��̬��Դ���Ⱪ¶·�� +file.staticAccessPath=/consume/image/uploadFile/** +#windows�µ�·������ +#file.rootPath=E: +#Linux�µ�·������ +file.rootPath=/root + +file.sonPath=/consume/image/uploadFile/ +#aopע�� +spring.aop.proxy-target-class=true +#token�ܳ� +token.secret=btn +#С����appId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 +#�����ɵ�֤������ +server.ssl.key-store=classpath:be.yangyoki.top.pfx +server.ssl.key-store-password=v9Q8z58R +server.ssl.keyStoreType=PKCS12 \ No newline at end of file diff --git a/target/classes/application-local.properties b/target/classes/application-local.properties new file mode 100644 index 0000000000000000000000000000000000000000..00d06e6e5fa1c8cc728985596f493e8ecded8b78 --- /dev/null +++ b/target/classes/application-local.properties @@ -0,0 +1,46 @@ +server.port=9066 + +##jdbc���� mysql 8.1���ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://47.93.196.206:3306/consume-van +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=btn +spring.datasource.password=btn + +##jdbc���� mysql 8.1���°汾 +#spring.datasource.driver-class-name=com.mysql.jdbc.Driver +#spring.datasource.url=jdbc:mysql://localhost:3306/btn +#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +#spring.datasource.username=root +#spring.datasource.password=123456 + +## �����ýڵ�Ϊ�����Ľڵ㣬�����׽�������÷���spring�Ľڵ��£����������޷���ʶ�� +#ע�⣺һ��Ҫ��Ӧmapperӳ��xml�ļ�������·�� +mybatis.mapper-locations=classpath:com/library/nbt/dao/**/mapper/*.xml +mybatis.type-aliases-package=com.library.nbt.model.entity + +#����generatorConfig.xml ����ʱ��mybatis-generator:generate -e +db.driverLocation=D:\\Interest\\mybatis-generator-core-1.3.2\\lib\\mysql-connector-java-8.0.12.jar + + +#�����������ַ +spring.web.googleexcute=explorer +#Ҫ�򿪵���ַ +spring.web.loginurl=http://localhost:${server.port}/swagger-ui.html +#�Ƿ�Ҫ����ʱ������� +spring.web.isopenurl=true + +logging.config=classpath:log/local/logback.xml + +# ��̬��Դ���Ⱪ¶·�� +file.staticAccessPath=/springboot/btn/image/uploadFile/** +#linux�µ�·������ +file.rootPath=/home +file.sonPath=/springboot/btn/image/uploadFile/ +#aopע�� +spring.aop.proxy-target-class=true +#token�ܳ� +token.secret=btn +#С����appId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 \ No newline at end of file diff --git a/target/classes/application-prod.properties b/target/classes/application-prod.properties new file mode 100644 index 0000000000000000000000000000000000000000..bb350f8bc78bd9390212686ef03cdae38d38bce7 --- /dev/null +++ b/target/classes/application-prod.properties @@ -0,0 +1,34 @@ +server.port=12000 + +##jdbc���� mysql 8.1���ϰ汾 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.url=jdbc:mysql://47.93.196.206:3306/consume-van +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.username=btn +spring.datasource.password=btn + +#�����������ַ +spring.web.googleexcute=explorer +#Ҫ�򿪵���ַ +spring.web.loginurl=http://localhost:${server.port}/swagger-ui.html +#�Ƿ�Ҫ����ʱ������� +spring.web.isopenurl=true + +#logging.config=classpath:log/dev/logback.xml + +# ��̬��Դ���Ⱪ¶·�� +file.staticAccessPath=/btn/image/uploadFile/** +#windows�µ�·������ +#file.rootPath=E: +#Linux�µ�·������ +file.rootPath=/root + +file.sonPath=/btn/image/uploadFile/ +#aopע�� +spring.aop.proxy-target-class=true +#token�ܳ� +token.secret=btn + +#С����appId +wxMinProject.appId=wx883b407ed6f14b55 +wxMinProject.appSecret=0bfd634e3b155553593a8d297631a494 \ No newline at end of file diff --git a/target/classes/application.properties b/target/classes/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..257b30648523ed1765c075c8903efdea33a7a5c2 --- /dev/null +++ b/target/classes/application.properties @@ -0,0 +1 @@ +spring.profiles.active=dev \ No newline at end of file diff --git a/target/classes/be.yangyoki.top.pfx b/target/classes/be.yangyoki.top.pfx new file mode 100644 index 0000000000000000000000000000000000000000..3740eb5226f3743a26864ae5bb362ab2eb4394e2 Binary files /dev/null and b/target/classes/be.yangyoki.top.pfx differ diff --git a/target/classes/com/consume/application.class b/target/classes/com/consume/application.class new file mode 100644 index 0000000000000000000000000000000000000000..5438bed426b77aa91953a81a1c1d4088c5f89782 Binary files /dev/null and b/target/classes/com/consume/application.class differ diff --git a/target/classes/com/consume/commons/constants/ConsumeConstant.class b/target/classes/com/consume/commons/constants/ConsumeConstant.class new file mode 100644 index 0000000000000000000000000000000000000000..f5e8815076af30499be6308183fc9a9dd8f362dd Binary files /dev/null and b/target/classes/com/consume/commons/constants/ConsumeConstant.class differ diff --git a/target/classes/com/consume/commons/utils/CopyUtils.class b/target/classes/com/consume/commons/utils/CopyUtils.class new file mode 100644 index 0000000000000000000000000000000000000000..8e8e80b4ea74b7e0c28da4dff1eb692a7dff777e Binary files /dev/null and b/target/classes/com/consume/commons/utils/CopyUtils.class differ diff --git a/target/classes/com/consume/commons/utils/CusAccessObjectUtil.class b/target/classes/com/consume/commons/utils/CusAccessObjectUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..e20a3a1927a92adfa80c73b194d24b8d7c9512b8 Binary files /dev/null and b/target/classes/com/consume/commons/utils/CusAccessObjectUtil.class differ diff --git a/target/classes/com/consume/commons/utils/DateUtils.class b/target/classes/com/consume/commons/utils/DateUtils.class new file mode 100644 index 0000000000000000000000000000000000000000..e2c2bbe3c1730e084c698566eb89dac11fa7bdff Binary files /dev/null and b/target/classes/com/consume/commons/utils/DateUtils.class differ diff --git a/target/classes/com/consume/commons/utils/HtmlUtils.class b/target/classes/com/consume/commons/utils/HtmlUtils.class new file mode 100644 index 0000000000000000000000000000000000000000..ef00e74f6094a1b27eda658eb2e70012b7f7682b Binary files /dev/null and b/target/classes/com/consume/commons/utils/HtmlUtils.class differ diff --git a/target/classes/com/consume/commons/utils/JwtUtils.class b/target/classes/com/consume/commons/utils/JwtUtils.class new file mode 100644 index 0000000000000000000000000000000000000000..1bac1dbd7e87fc1b7eb8fa55077d5037616d9cb5 Binary files /dev/null and b/target/classes/com/consume/commons/utils/JwtUtils.class differ diff --git a/target/classes/com/consume/commons/utils/MyX509TrustManager.class b/target/classes/com/consume/commons/utils/MyX509TrustManager.class new file mode 100644 index 0000000000000000000000000000000000000000..0d68f91d37115c7f24da816076bb34521224be09 Binary files /dev/null and b/target/classes/com/consume/commons/utils/MyX509TrustManager.class differ diff --git a/target/classes/com/consume/commons/utils/RandomValidateCodeUtil.class b/target/classes/com/consume/commons/utils/RandomValidateCodeUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..7e5580d1a26c7990e06ce955034c359a6dc459a7 Binary files /dev/null and b/target/classes/com/consume/commons/utils/RandomValidateCodeUtil.class differ diff --git a/target/classes/com/consume/commons/utils/Result.class b/target/classes/com/consume/commons/utils/Result.class new file mode 100644 index 0000000000000000000000000000000000000000..49d4d93b16c465abf2879d78a6651b422fd7fcda Binary files /dev/null and b/target/classes/com/consume/commons/utils/Result.class differ diff --git a/target/classes/com/consume/commons/utils/ResultUtil.class b/target/classes/com/consume/commons/utils/ResultUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..4b87df5f6a5518261f458c5aad174d6afc0dae59 Binary files /dev/null and b/target/classes/com/consume/commons/utils/ResultUtil.class differ diff --git a/target/classes/com/consume/commons/utils/Test.class b/target/classes/com/consume/commons/utils/Test.class new file mode 100644 index 0000000000000000000000000000000000000000..fe8fa9f47e213eee9a1f49b3e245cb85d7e23c49 Binary files /dev/null and b/target/classes/com/consume/commons/utils/Test.class differ diff --git a/target/classes/com/consume/commons/utils/VerifyUtil.class b/target/classes/com/consume/commons/utils/VerifyUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..5e4596398dc3c6e4fb5ac2d6db4cbd61d4c1635b Binary files /dev/null and b/target/classes/com/consume/commons/utils/VerifyUtil.class differ diff --git a/target/classes/com/consume/commons/utils/wechat/HttpUtil.class b/target/classes/com/consume/commons/utils/wechat/HttpUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..db42e2c95169126b43c6a4b5313bbf35e40064d9 Binary files /dev/null and b/target/classes/com/consume/commons/utils/wechat/HttpUtil.class differ diff --git a/target/classes/com/consume/commons/utils/wechat/MyX509TrustManager.class b/target/classes/com/consume/commons/utils/wechat/MyX509TrustManager.class new file mode 100644 index 0000000000000000000000000000000000000000..b57abb7cb0536ee721bdbe9410edcf45bd0edced Binary files /dev/null and b/target/classes/com/consume/commons/utils/wechat/MyX509TrustManager.class differ diff --git a/target/classes/com/consume/commons/utils/wechat/WeixinUtil.class b/target/classes/com/consume/commons/utils/wechat/WeixinUtil.class new file mode 100644 index 0000000000000000000000000000000000000000..f9016d6ea46ddb708ef2e5614495dfe49647468f Binary files /dev/null and b/target/classes/com/consume/commons/utils/wechat/WeixinUtil.class differ diff --git a/target/classes/com/consume/config/AuthenticationInterceptor.class b/target/classes/com/consume/config/AuthenticationInterceptor.class new file mode 100644 index 0000000000000000000000000000000000000000..12fe2a1b92bd17ab8e5a9f0fb7582b45db7eac89 Binary files /dev/null and b/target/classes/com/consume/config/AuthenticationInterceptor.class differ diff --git a/target/classes/com/consume/config/MyWebMvcConfigurerAdapter.class b/target/classes/com/consume/config/MyWebMvcConfigurerAdapter.class new file mode 100644 index 0000000000000000000000000000000000000000..44fa34a6ae9d5a35db61c73db89ea42c9babacd3 Binary files /dev/null and b/target/classes/com/consume/config/MyWebMvcConfigurerAdapter.class differ diff --git a/target/classes/com/consume/config/StepExecutorConfig.class b/target/classes/com/consume/config/StepExecutorConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..fe892e527b8da6a9fad07285da09ddc79072195d Binary files /dev/null and b/target/classes/com/consume/config/StepExecutorConfig.class differ diff --git a/target/classes/com/consume/config/SwaggerConfig.class b/target/classes/com/consume/config/SwaggerConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..15781baf99b810688c7df25461258cb68ced78fb Binary files /dev/null and b/target/classes/com/consume/config/SwaggerConfig.class differ diff --git a/target/classes/com/consume/config/WebMvcConfig.class b/target/classes/com/consume/config/WebMvcConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..91dff3e86e0f1afceb4e345373d349de091fe9cf Binary files /dev/null and b/target/classes/com/consume/config/WebMvcConfig.class differ diff --git a/target/classes/com/consume/controller/BookkeepingController.class b/target/classes/com/consume/controller/BookkeepingController.class new file mode 100644 index 0000000000000000000000000000000000000000..38388e15fad7e5d841b4eed979eba9b72f6e00d6 Binary files /dev/null and b/target/classes/com/consume/controller/BookkeepingController.class differ diff --git a/target/classes/com/consume/controller/ConsumeTypeController.class b/target/classes/com/consume/controller/ConsumeTypeController.class new file mode 100644 index 0000000000000000000000000000000000000000..f6f6ed3c415e94c6290049353dcae4ef1a34a27e Binary files /dev/null and b/target/classes/com/consume/controller/ConsumeTypeController.class differ diff --git a/target/classes/com/consume/controller/TokenTest.class b/target/classes/com/consume/controller/TokenTest.class new file mode 100644 index 0000000000000000000000000000000000000000..5d34203653a5689242cf7f784cd466ca25e9b06c Binary files /dev/null and b/target/classes/com/consume/controller/TokenTest.class differ diff --git a/target/classes/com/consume/controller/UploadController.class b/target/classes/com/consume/controller/UploadController.class new file mode 100644 index 0000000000000000000000000000000000000000..e14ba6b9ef83e73e8bb4c2c1cfb6588a9c2d08d0 Binary files /dev/null and b/target/classes/com/consume/controller/UploadController.class differ diff --git a/target/classes/com/consume/controller/WxFormIdController.class b/target/classes/com/consume/controller/WxFormIdController.class new file mode 100644 index 0000000000000000000000000000000000000000..406d317772cd50b64200791e5b718a1456dc930b Binary files /dev/null and b/target/classes/com/consume/controller/WxFormIdController.class differ diff --git a/target/classes/com/consume/controller/WxUserController.class b/target/classes/com/consume/controller/WxUserController.class new file mode 100644 index 0000000000000000000000000000000000000000..bca523ac8ab20af95389ec5f8e19f4c68666c307 Binary files /dev/null and b/target/classes/com/consume/controller/WxUserController.class differ diff --git a/target/classes/com/consume/dao/AccessTokenDao.class b/target/classes/com/consume/dao/AccessTokenDao.class new file mode 100644 index 0000000000000000000000000000000000000000..c5ebad8b0db3d69a624528725a9f4ea38fd3e0d7 Binary files /dev/null and b/target/classes/com/consume/dao/AccessTokenDao.class differ diff --git a/target/classes/com/consume/dao/AccountDetailDao.class b/target/classes/com/consume/dao/AccountDetailDao.class new file mode 100644 index 0000000000000000000000000000000000000000..61e8fd3a5978595403d2cdad37c9dc03a9934873 Binary files /dev/null and b/target/classes/com/consume/dao/AccountDetailDao.class differ diff --git a/target/classes/com/consume/dao/AccountTypeDao.class b/target/classes/com/consume/dao/AccountTypeDao.class new file mode 100644 index 0000000000000000000000000000000000000000..eb47d1f4d41380eaa2506b8e025e8eb333d7e3d6 Binary files /dev/null and b/target/classes/com/consume/dao/AccountTypeDao.class differ diff --git a/target/classes/com/consume/dao/AssetsDao.class b/target/classes/com/consume/dao/AssetsDao.class new file mode 100644 index 0000000000000000000000000000000000000000..82d69950a513e1100cd54d6afeee6c24079335db Binary files /dev/null and b/target/classes/com/consume/dao/AssetsDao.class differ diff --git a/target/classes/com/consume/dao/AssetsDetailDao.class b/target/classes/com/consume/dao/AssetsDetailDao.class new file mode 100644 index 0000000000000000000000000000000000000000..d529a0a465924913618dba75fdd9a74d328b8918 Binary files /dev/null and b/target/classes/com/consume/dao/AssetsDetailDao.class differ diff --git a/target/classes/com/consume/dao/BookkeepingDao.class b/target/classes/com/consume/dao/BookkeepingDao.class new file mode 100644 index 0000000000000000000000000000000000000000..0e0d46a12bd146ad1a2fecb468830f8f1b005e94 Binary files /dev/null and b/target/classes/com/consume/dao/BookkeepingDao.class differ diff --git a/target/classes/com/consume/dao/BookkeepingDetailDao.class b/target/classes/com/consume/dao/BookkeepingDetailDao.class new file mode 100644 index 0000000000000000000000000000000000000000..402277cbdcbcb1c3165e3ca85291981b21b812dc Binary files /dev/null and b/target/classes/com/consume/dao/BookkeepingDetailDao.class differ diff --git a/target/classes/com/consume/dao/ConsumeTypeDao.class b/target/classes/com/consume/dao/ConsumeTypeDao.class new file mode 100644 index 0000000000000000000000000000000000000000..e5b9c00fd7bb82da1188579a39978614cc646a7a Binary files /dev/null and b/target/classes/com/consume/dao/ConsumeTypeDao.class differ diff --git a/target/classes/com/consume/dao/WxFormIdDao.class b/target/classes/com/consume/dao/WxFormIdDao.class new file mode 100644 index 0000000000000000000000000000000000000000..98e2d68c6ac1f183c76727e81966a1a3b579993e Binary files /dev/null and b/target/classes/com/consume/dao/WxFormIdDao.class differ diff --git a/target/classes/com/consume/dao/WxUserDao.class b/target/classes/com/consume/dao/WxUserDao.class new file mode 100644 index 0000000000000000000000000000000000000000..5a389f33e9707b8491fa972ed14892f6d1838c47 Binary files /dev/null and b/target/classes/com/consume/dao/WxUserDao.class differ diff --git a/target/classes/com/consume/model/entity/AccessToken.class b/target/classes/com/consume/model/entity/AccessToken.class new file mode 100644 index 0000000000000000000000000000000000000000..524d565b391d3cd06a5d49a08159853880f1ad85 Binary files /dev/null and b/target/classes/com/consume/model/entity/AccessToken.class differ diff --git a/target/classes/com/consume/model/entity/AccountDetail.class b/target/classes/com/consume/model/entity/AccountDetail.class new file mode 100644 index 0000000000000000000000000000000000000000..5a1025616792066badb321a379de39327550318e Binary files /dev/null and b/target/classes/com/consume/model/entity/AccountDetail.class differ diff --git a/target/classes/com/consume/model/entity/AccountType.class b/target/classes/com/consume/model/entity/AccountType.class new file mode 100644 index 0000000000000000000000000000000000000000..67c20eebf07d0479cc9ea42835f5bb7b7e271214 Binary files /dev/null and b/target/classes/com/consume/model/entity/AccountType.class differ diff --git a/target/classes/com/consume/model/entity/Assets.class b/target/classes/com/consume/model/entity/Assets.class new file mode 100644 index 0000000000000000000000000000000000000000..614510f9cae54ded0d9bae3111d3b000b989d25f Binary files /dev/null and b/target/classes/com/consume/model/entity/Assets.class differ diff --git a/target/classes/com/consume/model/entity/AssetsDetail.class b/target/classes/com/consume/model/entity/AssetsDetail.class new file mode 100644 index 0000000000000000000000000000000000000000..8cf6bf881f05b3f397be6d124abc6b4890068f03 Binary files /dev/null and b/target/classes/com/consume/model/entity/AssetsDetail.class differ diff --git a/target/classes/com/consume/model/entity/BaseEntity.class b/target/classes/com/consume/model/entity/BaseEntity.class new file mode 100644 index 0000000000000000000000000000000000000000..0e8c707a38ab079ae9b481b8a4a14c36b01c251c Binary files /dev/null and b/target/classes/com/consume/model/entity/BaseEntity.class differ diff --git a/target/classes/com/consume/model/entity/Bookkeeping.class b/target/classes/com/consume/model/entity/Bookkeeping.class new file mode 100644 index 0000000000000000000000000000000000000000..2971073771dfa7425b3c478c1192ad47c634679c Binary files /dev/null and b/target/classes/com/consume/model/entity/Bookkeeping.class differ diff --git a/target/classes/com/consume/model/entity/BookkeepingDetail.class b/target/classes/com/consume/model/entity/BookkeepingDetail.class new file mode 100644 index 0000000000000000000000000000000000000000..20176acd3230ad59e7b0ea9f55d44577ee0b806c Binary files /dev/null and b/target/classes/com/consume/model/entity/BookkeepingDetail.class differ diff --git a/target/classes/com/consume/model/entity/ConsumeType.class b/target/classes/com/consume/model/entity/ConsumeType.class new file mode 100644 index 0000000000000000000000000000000000000000..78c6aa356dfb605fac842db0bbe82d4fc3e170e0 Binary files /dev/null and b/target/classes/com/consume/model/entity/ConsumeType.class differ diff --git a/target/classes/com/consume/model/entity/WxFormId.class b/target/classes/com/consume/model/entity/WxFormId.class new file mode 100644 index 0000000000000000000000000000000000000000..4d4ae3de78ad68a56e2983c7f6e7ac0bb79730cd Binary files /dev/null and b/target/classes/com/consume/model/entity/WxFormId.class differ diff --git a/target/classes/com/consume/model/entity/WxMinTemplateProject.class b/target/classes/com/consume/model/entity/WxMinTemplateProject.class new file mode 100644 index 0000000000000000000000000000000000000000..ad241671040cbc2734e01a78e6dac48310968138 Binary files /dev/null and b/target/classes/com/consume/model/entity/WxMinTemplateProject.class differ diff --git a/target/classes/com/consume/model/entity/WxUser.class b/target/classes/com/consume/model/entity/WxUser.class new file mode 100644 index 0000000000000000000000000000000000000000..e221ada8b3d6d3987b3a7f03ba28763acc9450d5 Binary files /dev/null and b/target/classes/com/consume/model/entity/WxUser.class differ diff --git a/target/classes/com/consume/model/view/AccessTokenView.class b/target/classes/com/consume/model/view/AccessTokenView.class new file mode 100644 index 0000000000000000000000000000000000000000..cda7da23b876c3a453ec850b3839267ad35d03ba Binary files /dev/null and b/target/classes/com/consume/model/view/AccessTokenView.class differ diff --git a/target/classes/com/consume/model/view/AccountDetailView.class b/target/classes/com/consume/model/view/AccountDetailView.class new file mode 100644 index 0000000000000000000000000000000000000000..a25e2f257566e00700f7f2470a896ffbff1c486e Binary files /dev/null and b/target/classes/com/consume/model/view/AccountDetailView.class differ diff --git a/target/classes/com/consume/model/view/AccountTypeView.class b/target/classes/com/consume/model/view/AccountTypeView.class new file mode 100644 index 0000000000000000000000000000000000000000..bbdbb218ec51b54c4279b03b83e9ea6398073c59 Binary files /dev/null and b/target/classes/com/consume/model/view/AccountTypeView.class differ diff --git a/target/classes/com/consume/model/view/AssetsDetailView.class b/target/classes/com/consume/model/view/AssetsDetailView.class new file mode 100644 index 0000000000000000000000000000000000000000..53dcb23db93ffce32b15df3c1210b4bf437fe6cc Binary files /dev/null and b/target/classes/com/consume/model/view/AssetsDetailView.class differ diff --git a/target/classes/com/consume/model/view/AssetsView.class b/target/classes/com/consume/model/view/AssetsView.class new file mode 100644 index 0000000000000000000000000000000000000000..ead1a3685458648804873affc552b6c29a08ae9e Binary files /dev/null and b/target/classes/com/consume/model/view/AssetsView.class differ diff --git a/target/classes/com/consume/model/view/BookkeepingDetailView.class b/target/classes/com/consume/model/view/BookkeepingDetailView.class new file mode 100644 index 0000000000000000000000000000000000000000..63f02e3647918f3fd8f9223e5b454742204a3c67 Binary files /dev/null and b/target/classes/com/consume/model/view/BookkeepingDetailView.class differ diff --git a/target/classes/com/consume/model/view/BookkeepingView.class b/target/classes/com/consume/model/view/BookkeepingView.class new file mode 100644 index 0000000000000000000000000000000000000000..db88c28d4842819700a3f5640f85fb97bbe4f620 Binary files /dev/null and b/target/classes/com/consume/model/view/BookkeepingView.class differ diff --git a/target/classes/com/consume/model/view/ConsumeTypeView.class b/target/classes/com/consume/model/view/ConsumeTypeView.class new file mode 100644 index 0000000000000000000000000000000000000000..c6df1a32a2fb1ced5c3dd500c92a4fac38e3ea93 Binary files /dev/null and b/target/classes/com/consume/model/view/ConsumeTypeView.class differ diff --git a/target/classes/com/consume/model/view/WxFormIdView.class b/target/classes/com/consume/model/view/WxFormIdView.class new file mode 100644 index 0000000000000000000000000000000000000000..5b416802788f5dfbd55509704a073d8283554ac7 Binary files /dev/null and b/target/classes/com/consume/model/view/WxFormIdView.class differ diff --git a/target/classes/com/consume/model/view/WxUserView.class b/target/classes/com/consume/model/view/WxUserView.class new file mode 100644 index 0000000000000000000000000000000000000000..318b28112def1eb4b1d7233a06ba2f94153072b1 Binary files /dev/null and b/target/classes/com/consume/model/view/WxUserView.class differ diff --git a/target/classes/com/consume/scheduler/TestScheduler.class b/target/classes/com/consume/scheduler/TestScheduler.class new file mode 100644 index 0000000000000000000000000000000000000000..33a899ea7065e894bbc674ea2b7875eee1fb98de Binary files /dev/null and b/target/classes/com/consume/scheduler/TestScheduler.class differ diff --git a/target/classes/com/consume/service/AccessTokenService.class b/target/classes/com/consume/service/AccessTokenService.class new file mode 100644 index 0000000000000000000000000000000000000000..024315bead40e50c1a27c452e5ca3d5423134a5c Binary files /dev/null and b/target/classes/com/consume/service/AccessTokenService.class differ diff --git a/target/classes/com/consume/service/AccountDetailService.class b/target/classes/com/consume/service/AccountDetailService.class new file mode 100644 index 0000000000000000000000000000000000000000..a6012bad16a8e7ec76267750936fef7a2d6555a3 Binary files /dev/null and b/target/classes/com/consume/service/AccountDetailService.class differ diff --git a/target/classes/com/consume/service/AccountTypeService.class b/target/classes/com/consume/service/AccountTypeService.class new file mode 100644 index 0000000000000000000000000000000000000000..d5328616904b12788055fe2e3500bdc8f8ab4437 Binary files /dev/null and b/target/classes/com/consume/service/AccountTypeService.class differ diff --git a/target/classes/com/consume/service/AssetsDetailService.class b/target/classes/com/consume/service/AssetsDetailService.class new file mode 100644 index 0000000000000000000000000000000000000000..3c33ab2a9840cc2a2a72258782563453ab669b4e Binary files /dev/null and b/target/classes/com/consume/service/AssetsDetailService.class differ diff --git a/target/classes/com/consume/service/AssetsService.class b/target/classes/com/consume/service/AssetsService.class new file mode 100644 index 0000000000000000000000000000000000000000..6d44822b6aad75630e29690b66ed0333aa81e4c6 Binary files /dev/null and b/target/classes/com/consume/service/AssetsService.class differ diff --git a/target/classes/com/consume/service/BaseService.class b/target/classes/com/consume/service/BaseService.class new file mode 100644 index 0000000000000000000000000000000000000000..5db0673b3141bccb995c84929682a04a7cafdf70 Binary files /dev/null and b/target/classes/com/consume/service/BaseService.class differ diff --git a/target/classes/com/consume/service/BookkeepingDetailService.class b/target/classes/com/consume/service/BookkeepingDetailService.class new file mode 100644 index 0000000000000000000000000000000000000000..19927a7659af75ae1ca9a026b13d9cf26737914a Binary files /dev/null and b/target/classes/com/consume/service/BookkeepingDetailService.class differ diff --git a/target/classes/com/consume/service/BookkeepingService.class b/target/classes/com/consume/service/BookkeepingService.class new file mode 100644 index 0000000000000000000000000000000000000000..9a0c76412ea37754beeb85868bb9baeb10015ea0 Binary files /dev/null and b/target/classes/com/consume/service/BookkeepingService.class differ diff --git a/target/classes/com/consume/service/ConsumeTypeService.class b/target/classes/com/consume/service/ConsumeTypeService.class new file mode 100644 index 0000000000000000000000000000000000000000..db9bee804ed0cce027008bf9e86c364794fe66f7 Binary files /dev/null and b/target/classes/com/consume/service/ConsumeTypeService.class differ diff --git a/target/classes/com/consume/service/WxFormIdService.class b/target/classes/com/consume/service/WxFormIdService.class new file mode 100644 index 0000000000000000000000000000000000000000..21e27a4af87446b56d9ccecc20f1ccd009ef3961 Binary files /dev/null and b/target/classes/com/consume/service/WxFormIdService.class differ diff --git a/target/classes/com/consume/service/WxTemplateMessageService.class b/target/classes/com/consume/service/WxTemplateMessageService.class new file mode 100644 index 0000000000000000000000000000000000000000..52f124d48daefe3c83ca180dec908ba59df3273f Binary files /dev/null and b/target/classes/com/consume/service/WxTemplateMessageService.class differ diff --git a/target/classes/com/consume/service/WxUserService.class b/target/classes/com/consume/service/WxUserService.class new file mode 100644 index 0000000000000000000000000000000000000000..4f9d3bcda1a037de7ac07b12a9d4f69ee4b55cdc Binary files /dev/null and b/target/classes/com/consume/service/WxUserService.class differ diff --git a/target/classes/com/consume/service/impl/AccessTokenServiceImpl.class b/target/classes/com/consume/service/impl/AccessTokenServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..3bd972d27ce2d21b03ec473ee60edef51208dbcf Binary files /dev/null and b/target/classes/com/consume/service/impl/AccessTokenServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/AccountDetailServiceImpl.class b/target/classes/com/consume/service/impl/AccountDetailServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..412ee100b830acd940bbe893488377a889bc7088 Binary files /dev/null and b/target/classes/com/consume/service/impl/AccountDetailServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/AccountTypeServiceImpl.class b/target/classes/com/consume/service/impl/AccountTypeServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..b85fa76a4371330b64f6c4b7677452658aa26861 Binary files /dev/null and b/target/classes/com/consume/service/impl/AccountTypeServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/AssetsDetailServiceImpl.class b/target/classes/com/consume/service/impl/AssetsDetailServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..2b30d182d82c929b885690a6da39297ae811e60a Binary files /dev/null and b/target/classes/com/consume/service/impl/AssetsDetailServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/AssetsServiceImpl.class b/target/classes/com/consume/service/impl/AssetsServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..f62151e55b022513ba2b3b1849b9b29a2b98db83 Binary files /dev/null and b/target/classes/com/consume/service/impl/AssetsServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/BookkeepingDetailServiceImpl.class b/target/classes/com/consume/service/impl/BookkeepingDetailServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..20e7e9011c0f2d87849f5e5e6db6cec14a6028bc Binary files /dev/null and b/target/classes/com/consume/service/impl/BookkeepingDetailServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/BookkeepingServiceImpl.class b/target/classes/com/consume/service/impl/BookkeepingServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..e42fbee034280765c74e9c0bd504eee7446e9875 Binary files /dev/null and b/target/classes/com/consume/service/impl/BookkeepingServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/ConsumeTypeServiceImpl.class b/target/classes/com/consume/service/impl/ConsumeTypeServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..895064b14b936a931279fcb09f03af5be12dd590 Binary files /dev/null and b/target/classes/com/consume/service/impl/ConsumeTypeServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/WxFormIdServiceImpl.class b/target/classes/com/consume/service/impl/WxFormIdServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..a22304fcc24f24005047cdb9d3e5616e996164e3 Binary files /dev/null and b/target/classes/com/consume/service/impl/WxFormIdServiceImpl.class differ diff --git a/target/classes/com/consume/service/impl/WxTemplateMessageSerivceImpl.class b/target/classes/com/consume/service/impl/WxTemplateMessageSerivceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..840fa5a23a15c1d7c640d6eaeef87dbb088db94f Binary files /dev/null and b/target/classes/com/consume/service/impl/WxTemplateMessageSerivceImpl.class differ diff --git a/target/classes/com/consume/service/impl/WxUserServiceImpl.class b/target/classes/com/consume/service/impl/WxUserServiceImpl.class new file mode 100644 index 0000000000000000000000000000000000000000..e3b2a082bdaeb0ae6c3f3aa3073c8a309f45b6b7 Binary files /dev/null and b/target/classes/com/consume/service/impl/WxUserServiceImpl.class differ diff --git a/target/consume-be-1.0-SNAPSHOT.jar b/target/consume-be-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..7b6b28d0719b85d219fe803dd9aa3c45c7e268e7 Binary files /dev/null and b/target/consume-be-1.0-SNAPSHOT.jar differ diff --git a/target/consume-be-1.0-SNAPSHOT.jar.original b/target/consume-be-1.0-SNAPSHOT.jar.original new file mode 100644 index 0000000000000000000000000000000000000000..1cc52e60732b16cf30e6c8e49c26a246ae08f2b6 Binary files /dev/null and b/target/consume-be-1.0-SNAPSHOT.jar.original differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000000000000000000000000000000000000..abb0016bb02731b6a05b4dd58b108f8e383eadf0 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.6.0 +version=1.0-SNAPSHOT +groupId=com.consume +artifactId=consume-be diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..4c8d2f7d9e22d071a07fd4d301e633672cd7b133 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,68 @@ +com\consume\commons\utils\RandomValidateCodeUtil.class +com\consume\model\entity\Assets.class +com\consume\dao\ConsumeTypeDao.class +com\consume\dao\BookkeepingDetailDao.class +com\consume\service\impl\AssetsDetailServiceImpl.class +com\consume\model\view\ConsumeTypeView.class +com\consume\service\AccountTypeService.class +com\consume\model\view\WxUserView.class +com\consume\commons\constants\ConsumeConstant.class +com\consume\service\BookkeepingDetailService.class +com\consume\dao\AssetsDetailDao.class +com\consume\commons\utils\ResultUtil.class +com\consume\controller\WxUserController.class +com\consume\service\BookkeepingService.class +com\consume\model\entity\BaseEntity.class +com\consume\service\AccountDetailService.class +com\consume\model\entity\AssetsDetail.class +com\consume\controller\BookkeepingController.class +com\consume\service\impl\ConsumeTypeServiceImpl.class +com\consume\controller\AssetsDetailController.class +com\consume\service\BaseService.class +com\consume\service\ConsumeTypeService.class +com\consume\dao\AssetsDao.class +com\consume\model\entity\Bookkeeping.class +com\consume\commons\utils\MyX509TrustManager.class +com\consume\controller\ConsumeTypeController.class +com\consume\scheduler\TestScheduler.class +com\consume\commons\utils\WxMinProjectUtils.class +com\consume\controller\TokenTest.class +com\consume\dao\AccountTypeDao.class +com\consume\model\entity\BookkeepingDetail.class +com\consume\service\impl\AccountTypeServiceImpl.class +com\consume\controller\UploadController.class +com\consume\dao\BookkeepingDao.class +com\consume\dao\AccountDetailDao.class +com\consume\commons\utils\JwtUtils.class +com\consume\service\WxUserService.class +com\consume\commons\utils\Result.class +com\consume\config\SwaggerConfig.class +com\consume\config\WebMvcConfig.class +com\consume\service\AssetsService.class +com\consume\service\impl\AccountDetailServiceImpl.class +com\consume\dao\WxUserDao.class +com\consume\model\entity\ConsumeType.class +com\consume\model\entity\AccountType.class +com\consume\commons\utils\CopyUtils.class +com\consume\commons\utils\DateUtils.class +com\consume\config\StepExecutorConfig.class +com\consume\application.class +com\consume\model\view\BookkeepingView.class +com\consume\service\AssetsDetailService.class +com\consume\service\impl\BookkeepingServiceImpl.class +com\consume\commons\utils\HtmlUtils.class +com\consume\service\impl\WxUserServiceImpl.class +com\consume\commons\utils\Test.class +com\consume\model\view\AccountDetailView.class +com\consume\model\view\AccountTypeView.class +com\consume\model\view\AssetsView.class +com\consume\commons\utils\CusAccessObjectUtil.class +com\consume\commons\utils\VerifyUtil.class +com\consume\model\view\BookkeepingDetailView.class +com\consume\service\impl\BookkeepingDetailServiceImpl.class +com\consume\service\impl\AssetsServiceImpl.class +com\consume\model\view\AssetsDetailView.class +com\consume\config\MyWebMvcConfigurerAdapter.class +com\consume\config\AuthenticationInterceptor.class +com\consume\model\entity\AccountDetail.class +com\consume\model\entity\WxUser.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..16cc8fefa889b3fd2393b5af32727b6658b064ca --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,68 @@ +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\CusAccessObjectUtil.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\UploadController.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\RandomValidateCodeUtil.java +E:\ϸ\consume-be\src\main\java\com\consume\config\StepExecutorConfig.java +E:\ϸ\consume-be\src\main\java\com\consume\scheduler\TestScheduler.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\AccountDetail.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\AccountType.java +E:\ϸ\consume-be\src\main\java\com\consume\service\BookkeepingDetailService.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\BookkeepingDetailView.java +E:\ϸ\consume-be\src\main\java\com\consume\config\WebMvcConfig.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\WxUser.java +E:\ϸ\consume-be\src\main\java\com\consume\service\AssetsService.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\Test.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\ConsumeTypeServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\BookkeepingDao.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\Bookkeeping.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\AssetsDetailDao.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\ConsumeTypeView.java +E:\ϸ\consume-be\src\main\java\com\consume\service\AssetsDetailService.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\AccountDetailServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\service\BookkeepingService.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\BookkeepingDetailServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\AccountDetailDao.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\WxUserView.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\Result.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\ConsumeType.java +E:\ϸ\consume-be\src\main\java\com\consume\application.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\AssetsDetailServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\service\ConsumeTypeService.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\HtmlUtils.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\BookkeepingView.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\MyX509TrustManager.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\constants\ConsumeConstant.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\AssetsDao.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\AccountDetailView.java +E:\ϸ\consume-be\src\main\java\com\consume\service\AccountTypeService.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\ConsumeTypeController.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\AssetsDetail.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\AssetsDetailView.java +E:\ϸ\consume-be\src\main\java\com\consume\service\AccountDetailService.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\ConsumeTypeDao.java +E:\ϸ\consume-be\src\main\java\com\consume\config\SwaggerConfig.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\WxUserDao.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\VerifyUtil.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\TokenTest.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\AssetsView.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\WxMinProjectUtils.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\BookkeepingDetailDao.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\CopyUtils.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\JwtUtils.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\BookkeepingController.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\AccountTypeServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\WxUserServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\model\view\AccountTypeView.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\AssetsDetailController.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\Assets.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\DateUtils.java +E:\ϸ\consume-be\src\main\java\com\consume\commons\utils\ResultUtil.java +E:\ϸ\consume-be\src\main\java\com\consume\dao\AccountTypeDao.java +E:\ϸ\consume-be\src\main\java\com\consume\service\BaseService.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\BaseEntity.java +E:\ϸ\consume-be\src\main\java\com\consume\model\entity\BookkeepingDetail.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\AssetsServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\service\impl\BookkeepingServiceImpl.java +E:\ϸ\consume-be\src\main\java\com\consume\controller\WxUserController.java +E:\ϸ\consume-be\src\main\java\com\consume\config\AuthenticationInterceptor.java +E:\ϸ\consume-be\src\main\java\com\consume\service\WxUserService.java +E:\ϸ\consume-be\src\main\java\com\consume\config\MyWebMvcConfigurerAdapter.java diff --git a/target/test-classes/com/consume/commons/utils/wechat/AccessToeknUtilsTest.class b/target/test-classes/com/consume/commons/utils/wechat/AccessToeknUtilsTest.class new file mode 100644 index 0000000000000000000000000000000000000000..e26a00f9132fbc44141bb8ff4e011038c55ed879 Binary files /dev/null and b/target/test-classes/com/consume/commons/utils/wechat/AccessToeknUtilsTest.class differ