作者:一片绿洲053766 | 来源:互联网 | 2023-08-19 21:48
PiggyMetrics项目下载地址:https://github.com/sqshq/PiggyMetrics
一、修复host文件
打开c:\Windows\System32\Drivers\etc\hosts文件,在文件最后,添加如下代码:
127.0.0.1 config registry auth-service rabbitmq account-service account-mongodb statistics-service statistics-mongodb notification-service notification-mongodb
二、MongoDB修改为MySQL
修改后的项目下载
MySQL数据库的SQL语句为:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for account
-- ----------------------------
DROP TABLE IF EXISTS `account`;
CREATE TABLE `account` (
`name` varchar(255) NOT NULL,
`last_seen` datetime DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for item
-- ----------------------------
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(64) NOT NULL AUTO_INCREMENT,
`account_name` varchar(255) NOT NULL COMMENT '用户名外键',
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`amount` decimal(64,0) DEFAULT NULL COMMENT '合计',
`currency` int(64) DEFAULT NULL COMMENT '货币类型',
`period` int(64) DEFAULT NULL COMMENT '时间段',
`icon` varchar(255) DEFAULT NULL,
`incomes_or_expenses` int(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for saving
-- ----------------------------
DROP TABLE IF EXISTS `saving`;
CREATE TABLE `saving` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`account_name` varchar(255) NOT NULL,
`amount` decimal(64,0) DEFAULT '0' COMMENT '存款金额',
`currency` int(64) DEFAULT '1' COMMENT '货币类型(1: USD,2: EUR,3: RUB)',
`interest` decimal(64,0) DEFAULT '0' COMMENT '利息',
`deposit` int(1) DEFAULT '1',
`capitalization` int(1) DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
config模块修改内容
config\src\main\resources\shared\account-service.yml文件中:
config\src\main\resources\shared\auth-service.yml文件中:
auth-service模块修改内容
auth-service\pom.xml
auth-service\src\main\java\com\piggymetrics\auth\domain\User.java
auth-service\src\main\java\com\piggymetrics\auth\AuthApplication.java
account-service模块修改内容
account-service\pom.xml
account-service\src\main\java\com\piggymetrics\account\domain\Account.java
account-service\src\main\java\com\piggymetrics\account\domain\Item.java
account-service\src\main\java\com\piggymetrics\account\domain\Saving.java
account-service\src\main\java\com\piggymetrics\account\service\AccountServiceImpl.java
新增account-service\src\main\java\com\piggymetrics\account\repository\ItemRepository.java
文件内容为:
package com.piggymetrics.account.repository;
import com.piggymetrics.account.domain.Item;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ItemRepository extends CrudRepository- {
}
新增account-service\src\main\java\com\piggymetrics\account\repository\SavingRepository.java
文件内容为:
package com.piggymetrics.account.repository;
import com.piggymetrics.account.domain.Saving;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface SavingRepository extends CrudRepository {
}
修改后的项目下载