Browse Source

代码同步

master
review512jwy@163.com 2 months ago
commit
2f69e2c6f2
  1. 16
      .gitignore
  2. 31
      document/cmd
  3. 85
      document/db/20240508.sql
  4. 62
      document/db/20240515.sql
  5. 161
      document/db/init.sql
  6. 30
      document/start.sh
  7. 17
      document/update.sh
  8. 15
      dongjian-center-admin-common/.gitignore
  9. 35
      dongjian-center-admin-common/pom.xml
  10. 29
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/Constants.java
  11. 36
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/exception/BusinessException.java
  12. 26
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/exception/MsgCodeException.java
  13. 26
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/PropertySourceYumFactory.java
  14. 38
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/MsgLanguageChange.java
  15. 25
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_CN.java
  16. 25
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_EN.java
  17. 25
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_JP.java
  18. 51
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/BaseResponse.java
  19. 401
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/PageInfo.java
  20. 66
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/PageResponse.java
  21. 32
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/ResponseCode.java
  22. 104
      dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/SimpleDataResponse.java
  23. 60
      dongjian-center-admin-common/src/main/resources/config/language/msg/msg_cn.yml
  24. 60
      dongjian-center-admin-common/src/main/resources/config/language/msg/msg_en.yml
  25. 60
      dongjian-center-admin-common/src/main/resources/config/language/msg/msg_jp.yml
  26. 15
      dongjian-center-admin-controller/.gitignore
  27. 11
      dongjian-center-admin-controller/buildPush-prod.sh
  28. 11
      dongjian-center-admin-controller/buildPush-staging.sh
  29. 70
      dongjian-center-admin-controller/dockerfile
  30. 545
      dongjian-center-admin-controller/pom.xml
  31. 20
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/DongjianAdminApplication.java
  32. 56
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/ApiConfig.java
  33. 38
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/CorsConfigurer.java
  34. 78
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/CrosXssFilter.java
  35. 92
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/RequestWrapper.java
  36. 73
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/interceptor/AccessApiInterceptor.java
  37. 10
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/interceptor/AccessRequired.java
  38. 103
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/AccountController.java
  39. 81
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/CommonController.java
  40. 138
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/CompanyController.java
  41. 35
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/HealthController.java
  42. 110
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/ProjectController.java
  43. 132
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/RoleController.java
  44. 54
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/SysEnvController.java
  45. 153
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/UserController.java
  46. 50
      dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/swagger/SwaggerConfig.java
  47. 59
      dongjian-center-admin-controller/src/main/resources/assembly.xml
  48. 175
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/main.tf
  49. 90
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/main.tf
  50. 19
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/output.tf
  51. 31
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/valiables.tf
  52. 63
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/main.tf
  53. 7
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/output.tf
  54. 44
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/valiables.tf
  55. 28
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/main.tf
  56. 0
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/output.tf
  57. 30
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/valiables.tf
  58. 52
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/main.tf
  59. 6
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/output.tf
  60. 25
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/variables.tf
  61. 141
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/main.tf
  62. 7
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/output.tf
  63. 68
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/valiables.tf
  64. 132
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/main.tf
  65. 42
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/output.tf
  66. 21
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/valiables.tf
  67. 613
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/main.tf
  68. 13
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/user_data.sh
  69. 366
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/valiables.tf
  70. 118
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/main.tf
  71. 0
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/output.tf
  72. 13
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/valiables.tf
  73. 42
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/main.tf
  74. 0
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/output.tf
  75. 12
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/valiables.tf
  76. 89
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/main.tf
  77. 7
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/output.tf
  78. 6
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/valiables.tf
  79. BIN
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/kinesisStreamToLambdaDemo-b9494dc1-fa94-4184-ab34-2707c917b543.zip
  80. 140
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/main.tf
  81. 3
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/output.tf
  82. 31
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/variables.tf
  83. 217
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/main.tf
  84. 3
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/output.tf
  85. 18
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/valiables.tf
  86. 68
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/main.tf
  87. 44
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/output.tf
  88. 69
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/variables.tf
  89. 145
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/init.sql
  90. 14
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/main.tf
  91. 7
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/output.tf
  92. 8
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/valiables.tf
  93. 15
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/output.tf
  94. 430
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/security_group.tf
  95. 10
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/variables.tf
  96. 15
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/output.tf
  97. 52
      dongjian-center-admin-controller/src/main/resources/aurora_terraform/variables.tf
  98. 176
      dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/main.tf
  99. 90
      dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/modules/alb/main.tf
  100. 19
      dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/modules/alb/output.tf

16
.gitignore

@ -0,0 +1,16 @@
/target/
/logs/
/.idea/
*.iml
*.bak
*.log
/.settings/
*.project
*.classpath
*.factorypath
*.springBeans
/.apt_generated/
/.externalToolBuilders/
/bin/
/dongjian-center-admin-controller/tmp/
application-*.properties

31
document/cmd

@ -0,0 +1,31 @@
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com
docker tag 67f91fc6cfbf 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest
docker push 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest
docker pull 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest
docker run -d -p 8887:20008 -v /home/data-center-business/back/application.properties:/home/data-center-business/config/application.properties 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business
aws configure
docker run -e apiEnable=false -e datasourceDNS=tokyo-building-db.caetvgb7diak.ap-northeast-1.rds.amazonaws.com -e datasourceTimeZone=Asia/Tokyo -e datasourceUsername=techsor -e datasourcePassword=Abc#123456xyz -e loggingLevel=ERROR -e loggingPath=/home/data-center-business/log -e loggingAppender=SYSLOG -e redisHost=replication-group-tokyo-build.ncvpel.ng.0001.apne1.cache.amazonaws.com -e redisPassword= -e awsAccesskey=AKIA5OFH5OOZHM3U3KX4 -e awsSecretkey=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 -e awsBucket=tokyo-build-databucket-381659385655 -e ibatisLoggingLog=ERROR -e ibatisLoggingLogFactory=ERROR -d -p 20008:20008 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest
阿里云
docker tag e1fe6f58961e registry.cn-shanghai.aliyuncs.com/test-data-business/data-business-server:latest
docker push registry.cn-shanghai.aliyuncs.com/test-data-business/data-business-server:latest
docker pull registry.cn-shanghai.aliyuncs.com/test-data-business/data-business-server:latest
docker exec -it 3c77bb84d338 /bin/bash
docker run -d -p 20008:20015 -v /home/application.properties:/home/dongjian-center-admin/config/application.properties registry.cn-shanghai.aliyuncs.com/test-data-business/data-business-server
测试环境
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com
docker tag ecee6b583d3c 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest
docker push 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-business:latest

85
document/db/20240508.sql

@ -0,0 +1,85 @@
USE `data_center_aeon_admin`;
DROP procedure IF EXISTS `add_column`;
DELIMITER $$
CREATE PROCEDURE add_column()
BEGIN
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'aurora_flag'
) THEN
ALTER TABLE basic_company
ADD COLUMN `aurora_flag` int DEFAULT '0' COMMENT '0-未创建,1-创建中,2-创建成功,3-创建失败';
END IF;
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'aurora_url'
) THEN
ALTER TABLE basic_company
ADD COLUMN `aurora_url` varchar(255) DEFAULT NULL;
END IF;
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'aurora_username'
) THEN
ALTER TABLE basic_company
ADD COLUMN `aurora_username` varchar(255) DEFAULT NULL;
END IF;
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'aurora_password'
) THEN
ALTER TABLE basic_company
ADD COLUMN `aurora_password` varchar(255) DEFAULT NULL;
END IF;
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'redis_db_id'
) THEN
ALTER TABLE basic_company
ADD COLUMN `redis_db_id` int DEFAULT NULL COMMENT '使用的redis库id';
END IF;
IF NOT EXISTS (
SELECT *
FROM information_schema.columns
WHERE table_schema = 'data_center_aeon_admin'
AND table_name = 'basic_company'
AND column_name = 'bearer_token'
) THEN
ALTER TABLE basic_company
ADD COLUMN `bearer_token` text;
END IF;
update basic_company set aurora_flag = 2 where aurora_url is not null;
END$$
DELIMITER ;
CALL add_column();
DROP procedure IF EXISTS `add_column`;

62
document/db/20240515.sql

@ -0,0 +1,62 @@
USE `data_center_aeon_admin`;
/*Table structure for table `basic_menu` */
DROP TABLE IF EXISTS `basic_menu`;
CREATE TABLE `basic_menu` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_menu_id` bigint DEFAULT NULL,
`menu_name` varchar(100) DEFAULT NULL,
`menu_name_en` varchar(100) DEFAULT NULL,
`menu_name_jp` varchar(100) DEFAULT NULL,
`remark` varchar(100) DEFAULT NULL,
`menu_level` int DEFAULT '1' COMMENT '菜单级别',
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`create_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_menu` */
insert into `basic_menu`(`id`,`parent_menu_id`,`menu_name`,`menu_name_en`,`menu_name_jp`,`remark`,`menu_level`,`flag`,`create_time`) values (1,-1,'项目管理','项目管理','プロジェクト管理','项目管理',1,0,1659079777164),(2,-1,'楼宇模块','楼宇模块','ビルモジュール','楼宇模块',1,0,1659079777164),(3,-1,'设备模块','设备模块','設備モジュール','设备模块',1,0,1659079777164),(4,-1,'转发管理','转发管理','転送管理','转发管理',1,0,1659079777164),(5,-1,'数据来源管理','数据来源管理','データ源管理','数据来源管理',1,0,1659079777164),(6,1,'添加','添加','追加','项目管理-添加',2,0,1659079777164),(7,1,'编辑','编辑','編集','项目管理-编辑',2,0,1659079777164),(8,1,'删除','删除','削除','项目管理-删除',2,0,1659079777164),(9,1,'批量添加','批量添加','大量に追加','项目管理-批量添加',2,0,1659079777164),(10,2,'楼宇管理','楼宇管理','ビル管理','楼宇管理',2,0,1659079777164),(11,2,'楼层管理','楼层管理','フロア管理','楼层管理',2,0,1659079777164),(12,2,'房间管理','房间管理','部屋管理','房间管理',2,0,1659079777164),(13,2,'资产管理','资产管理','資産管理','资产管理',2,0,1659079777164),(14,10,'添加','添加','追加','楼宇管理-添加',3,0,1659079777164),(15,10,'编辑','编辑','編集','楼宇管理-编辑',3,0,1659079777164),(16,10,'删除','删除','削除','楼宇管理-删除',3,0,1659079777164),(17,11,'添加','添加','追加','楼层管理-添加',3,0,1659079777164),(18,11,'编辑','编辑','編集','楼层管理-编辑',3,0,1659079777164),(19,11,'删除','删除','削除','楼层管理-删除',3,0,1659079777164),(20,12,'添加','添加','追加','房间管理-添加',3,0,1659079777164),(21,12,'编辑','编辑','編集','房间管理-编辑',3,0,1659079777164),(22,12,'删除','删除','削除','房间管理-删除',3,0,1659079777164),(23,13,'添加','添加','追加','资产管理-添加',3,0,1659079777164),(24,13,'编辑','编辑','編集','资产管理-编辑',3,0,1659079777164),(25,13,'删除','删除','削除','资产管理-删除',3,0,1659079777164),(26,3,'设备管理','设备管理','設備管理','设备管理',2,0,1659079777164),(27,26,'添加','添加','追加','设备管理-添加',3,0,1659079777164),(28,26,'编辑','编辑','編集','设备管理-编辑',3,0,1659079777164),(29,26,'删除','删除','削除','设备管理-删除',3,0,1659079777164),(30,26,'批量添加','批量添加','大量に追加','设备管理-批量添加',3,0,1659079777164),(31,26,'批量删除','批量删除','一括削除','设备管理-批量删除',3,0,1659079777164),(32,3,'设备类别管理','设备类别管理','設備の種類管理','设备类别管理',2,0,1659079777164),(33,32,'添加','添加','追加','设备类别管理-添加',3,0,1659079777164),(34,32,'编辑','编辑','編集','设备类别管理-编辑',3,0,1659079777164),(35,32,'删除','删除','削除','设备类别管理-删除',3,0,1659079777164),(36,4,'添加','添加','追加','转发管理-添加',3,0,1659079777164),(37,4,'编辑','编辑','編集','转发管理-编辑',3,0,1659079777164),(38,4,'删除','删除','削除','转发管理-删除',3,0,1659079777164),(39,5,'添加','添加','追加','数据来源管理-添加',3,0,1659079777164),(40,5,'编辑','编辑','編集','数据来源管理-编辑',3,0,1659079777164),(41,5,'删除','删除','削除','数据来源管理-删除',3,0,1659079777164),(42,26,'设置告警模板','设置告警模板','アラームテンプレートの設定','设备管理-设置告警模板',3,0,1659079777164);
/*Table structure for table `basic_role` */
DROP TABLE IF EXISTS `basic_role`;
CREATE TABLE `basic_role` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company_id` bigint DEFAULT NULL,
`role_name` varchar(100) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL,
`modifier_id` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_menu_relation` */
DROP TABLE IF EXISTS `basic_role_menu_relation`;
CREATE TABLE `basic_role_menu_relation` (
`role_id` bigint DEFAULT NULL,
`menu_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_user_relation` */
DROP TABLE IF EXISTS `basic_role_user_relation`;
CREATE TABLE `basic_role_user_relation` (
`user_id` bigint DEFAULT NULL,
`role_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

161
document/db/init.sql

@ -0,0 +1,161 @@
/*
SQLyog - MySQL GUI v8.14
MySQL - 8.0.28 : Database - data_center_aeon_admin
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`data_center_aeon_admin` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `data_center_aeon_admin`;
/*Table structure for table `basic_company` */
DROP TABLE IF EXISTS `basic_company`;
CREATE TABLE `basic_company` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_id` bigint DEFAULT NULL,
`company_name` varchar(500) DEFAULT NULL,
`mfa_switch` int DEFAULT '0' COMMENT '谷歌mfa服务开关。0-关闭,1-开启',
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`create_time` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
`apikey` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_company` */
insert into `basic_company`(`id`,`parent_id`,`company_name`,`mfa_switch`,`flag`,`create_time`,`modify_time`) values (1,-1,'MiniSolution',0,0,1658978002231,1658978002231);
/*Table structure for table `basic_menu` */
DROP TABLE IF EXISTS `basic_menu`;
CREATE TABLE `basic_menu` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_menu_id` bigint DEFAULT NULL,
`menu_name` varchar(100) DEFAULT NULL,
`menu_name_en` varchar(100) DEFAULT NULL,
`menu_name_jp` varchar(100) DEFAULT NULL,
`remark` varchar(100) DEFAULT NULL,
`menu_level` int DEFAULT '1' COMMENT '菜单级别',
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`create_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_menu` */
insert into `basic_menu`(`id`,`parent_menu_id`,`menu_name`,`menu_name_en`,`menu_name_jp`,`remark`,`menu_level`,`flag`,`create_time`) values (1,-1,'项目管理','项目管理','项目管理','项目管理',1,0,1659079777164),(2,-1,'楼宇模块','楼宇模块','楼宇模块','楼宇模块',1,0,1659079777164),(3,-1,'设备模块','设备模块','设备模块','设备模块',1,0,1659079777164),(4,-1,'转发管理','转发管理','转发管理','转发管理',1,0,1659079777164),(5,-1,'数据来源管理','数据来源管理','数据来源管理','数据来源管理',1,0,1659079777164),(6,1,'添加','添加','添加','项目管理-添加',2,0,1659079777164),(7,1,'编辑','编辑','编辑','项目管理-编辑',2,0,1659079777164),(8,1,'删除','删除','删除','项目管理-删除',2,0,1659079777164),(9,1,'批量添加','批量添加','批量添加','项目管理-批量添加',2,0,1659079777164),(10,2,'楼宇管理','楼宇管理','楼宇管理','楼宇管理',2,0,1659079777164),(11,2,'楼层管理','楼层管理','楼层管理','楼层管理',2,0,1659079777164),(12,2,'房间管理','房间管理','房间管理','房间管理',2,0,1659079777164),(13,2,'资产管理','资产管理','资产管理','资产管理',2,0,1659079777164),(14,10,'添加','添加','添加','楼宇管理-添加',3,0,1659079777164),(15,10,'编辑','编辑','编辑','楼宇管理-编辑',3,0,1659079777164),(16,10,'删除','删除','删除','楼宇管理-删除',3,0,1659079777164),(17,11,'添加','添加','添加','楼层管理-添加',3,0,1659079777164),(18,11,'编辑','编辑','编辑','楼层管理-编辑',3,0,1659079777164),(19,11,'删除','删除','删除','楼层管理-删除',3,0,1659079777164),(20,12,'添加','添加','添加','房间管理-添加',3,0,1659079777164),(21,12,'编辑','编辑','编辑','房间管理-编辑',3,0,1659079777164),(22,12,'删除','删除','删除','房间管理-删除',3,0,1659079777164),(23,13,'添加','添加','添加','资产管理-添加',3,0,1659079777164),(24,13,'编辑','编辑','编辑','资产管理-编辑',3,0,1659079777164),(25,13,'删除','删除','删除','资产管理-删除',3,0,1659079777164),(26,3,'设备管理','设备管理','设备管理','设备管理',2,0,1659079777164),(27,26,'添加','添加','添加','设备管理-添加',3,0,1659079777164),(28,26,'编辑','编辑','编辑','设备管理-编辑',3,0,1659079777164),(29,26,'删除','删除','删除','设备管理-删除',3,0,1659079777164),(30,26,'批量添加','批量添加','批量添加','设备管理-批量添加',3,0,1659079777164),(31,26,'批量删除','批量删除','批量删除','设备管理-批量删除',3,0,1659079777164),(32,3,'设备类别管理','设备类别管理','设备类别管理','设备类别管理',2,0,1659079777164),(33,32,'添加','添加','添加','设备类别管理-添加',3,0,1659079777164),(34,32,'编辑','编辑','编辑','设备类别管理-编辑',3,0,1659079777164),(35,32,'删除','删除','删除','设备类别管理-删除',3,0,1659079777164),(36,4,'添加','添加','添加','转发管理-添加',3,0,1659079777164),(37,4,'编辑','编辑','编辑','转发管理-编辑',3,0,1659079777164),(38,4,'删除','删除','删除','转发管理-删除',3,0,1659079777164),(39,5,'添加','添加','添加','数据来源管理-添加',3,0,1659079777164),(40,5,'编辑','编辑','编辑','数据来源管理-编辑',3,0,1659079777164),(41,5,'删除','删除','删除','数据来源管理-删除',3,0,1659079777164);
/*Table structure for table `basic_role` */
DROP TABLE IF EXISTS `basic_role`;
CREATE TABLE `basic_role` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company_id` bigint DEFAULT NULL,
`role_name` varchar(100) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL,
`modifier_id` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_menu_relation` */
DROP TABLE IF EXISTS `basic_role_menu_relation`;
CREATE TABLE `basic_role_menu_relation` (
`role_id` bigint DEFAULT NULL,
`menu_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_user_relation` */
DROP TABLE IF EXISTS `basic_role_user_relation`;
CREATE TABLE `basic_role_user_relation` (
`user_id` bigint DEFAULT NULL,
`role_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_user` */
DROP TABLE IF EXISTS `basic_user`;
CREATE TABLE `basic_user` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_type` int DEFAULT '0' COMMENT '0-未知,1-管理平台用户,2-普通平台用户',
`company_id` bigint NOT NULL,
`username` varchar(255) DEFAULT NULL,
`login_name` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`password_modify_time` bigint DEFAULT NULL,
`salt` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`mobile_number` varchar(255) DEFAULT NULL,
`mfa_secret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`mfa_bind` int DEFAULT '0' COMMENT '用户是否绑定了mfa设备。0-未绑定,1-已绑定',
`last_login_time` bigint DEFAULT NULL,
`flag` int NOT NULL DEFAULT '0' COMMENT '0-正常,1-删除',
`expire_time` bigint DEFAULT '4114487556000',
`create_time` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
`modifier_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_user` */
insert into `basic_user`(`id`,`user_type`,`company_id`,`username`,`login_name`,`password`,`password_modify_time`,`salt`,`email`,`mobile_number`,`mfa_secret`,`mfa_bind`,`last_login_time`,`flag`,`expire_time`,`create_time`,`creator_id`,`modify_time`,`modifier_id`) values (1,1,1,'admin','admin','nVg+buw0YAs=',1670312031273,'09bc3a7898','1053492832@qq.com',NULL,NULL,0,1706177793183,0,4114487556000,4114487556000,NULL,1670312031273,NULL);
/*Table structure for table `login_history` */
DROP TABLE IF EXISTS `login_history`;
CREATE TABLE `login_history` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`request_ip` varchar(255) DEFAULT NULL,
`login_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `worker_node` */
DROP TABLE IF EXISTS `worker_node`;
CREATE TABLE `worker_node` (
`ID` bigint NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
`HOST_NAME` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'host name',
`PORT` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'port',
`TYPE` int NOT NULL COMMENT 'node type: ACTUAL or CONTAINER',
`LAUNCH_DATE` date NOT NULL COMMENT 'launch date',
`MODIFIED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'modified time',
`CREATED` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'created time',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='DB WorkerID Assigner for UID Generator';
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

30
document/start.sh

@ -0,0 +1,30 @@
#! /bin/sh
#启动方法
start(){
now=`date "+%Y%m%d%H%M%S"`
cd /home/dongjian-center-admin/back/server/run && nohup /usr/local/java/jdk1.8.0_221/bin/java -server -Xms256m -Xmx256m -jar /home/dongjian-center-admin/back/server/run/dongjian-center-admin-controller-0.0.1-SNAPSHOT.jar > /dev/null 2>boot.log &
}
#停止方法
stop(){
ps -ef|grep java|grep dongjian-center-admin-controller-0.0.1-SNAPSHOT.jar|awk '{print $2}'|while read pid
do
kill -9 $pid
done
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
printf 'Usage: %s {start|stop|restart}\n' "$prog"
exit 1
;;
esac

17
document/update.sh

@ -0,0 +1,17 @@
#!/bin/bash
projectName=dongjian-center-admin
backFilePath=/home/$projectName/back/server
basepath=$(cd `dirname $0`; pwd)
cd $basepath
echo "start for Web"
rm -rf $backFilePath/run/lib
unzip -o $backFilePath/$projectName.zip -d $backFilePath/run
\cp -r $backFilePath/run/$projectName/* $backFilePath/run/
rm -rf $backFilePath/run/$projectName
sh start.sh restart
exit

15
dongjian-center-admin-common/.gitignore

@ -0,0 +1,15 @@
/target/
/logs/
/.idea/
*.iml
*.bak
*.log
/.settings/
*.project
*.classpath
*.factorypath
*.springBeans
/.apt_generated/
/.externalToolBuilders/
/bin/
application-*.properties

35
dongjian-center-admin-common/pom.xml

@ -0,0 +1,35 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dongjian-center-admin-common</artifactId>
<name>dongjian-center-admin-common</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin-util</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

29
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/Constants.java

@ -0,0 +1,29 @@
package com.dongjian.datacenter.admin.common;
/**
* @author Mr.Jiang
* @time 2022年5月20日 下午2:01:41
*/
public class Constants {
//这个很重要,不要随便动
public static final String DES_SALT = "ci3b512jwy199511";
public static final String APP_NAME = "dongjian_datacenter_admin:";
public static final int LOGIN_ATTEMPTS = 5;
public static final long LOGIN_LOCK_PERIOD = 3600000;//ms
public static final String LOGIN_FAIL = APP_NAME + "login_fail:%s";// 失败次数,过期时间为1小时
public static final String LOGIN_LOCK = APP_NAME + "login_lock:%s";// 锁定标志,值为 true,过期时间为1小时
//用户ID,登录名,企业ID,token
public static final String ACCESS_TOKEN_FORMAT = APP_NAME + "RequestHeader:AccessToken:{0}:{1}:{2}:{3}";
public static final String CAPTCHA_VERIFICATION = APP_NAME + "CAPTCHA:VERIFICATION:";
public static final String AURORA_URL_FORMAT ="jdbc:mysql://{0}:3306/third?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
public final static String DATA_TABLE_NAME = "rawData";
public static final String MOUNT_DIR = "/home/third-admin/mount";
}

36
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/exception/BusinessException.java

@ -0,0 +1,36 @@
package com.dongjian.datacenter.admin.common.exception;
/**
* 业务异常处理
*
*/
public class BusinessException extends RuntimeException{
/**
* 实例化一个新的业务异常
*
* @param msg 异常信息
*/
public BusinessException(String msg) {
super(msg);
}
/**
* 实例化一个新的业务异常
*
* @param cause 异常原因
*/
public BusinessException(Throwable cause) {
super(cause);
}
/**
* 实例化一个新的业务异常
*
* @param msg 异常信息
* @param cause 异常原因
*/
public BusinessException(String msg, Throwable cause) {
super(msg, cause);
}
}

26
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/exception/MsgCodeException.java

@ -0,0 +1,26 @@
package com.dongjian.datacenter.admin.common.exception;
/**
*
* @author jwy-style
*
*/
public class MsgCodeException extends RuntimeException{
private String message;
public MsgCodeException(String message) {
super(message);
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

26
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/PropertySourceYumFactory.java

@ -0,0 +1,26 @@
package com.dongjian.datacenter.admin.common.language;
import java.io.IOException;
import java.util.List;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.DefaultPropertySourceFactory;
import org.springframework.core.io.support.EncodedResource;
/**
* @PropertySource 解析.yum文件需要指定该工厂
*/
public class PropertySourceYumFactory extends DefaultPropertySourceFactory {
@Override
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
if (resource == null) {
return super.createPropertySource(name, resource);
}
List<PropertySource<?>> sources = new YamlPropertySourceLoader().load(resource.getResource().getFilename(), resource.getResource());
return sources.get(0);
}
}

38
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/MsgLanguageChange.java

@ -0,0 +1,38 @@
package com.dongjian.datacenter.admin.common.language.msg;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class MsgLanguageChange {
@Autowired
private Msg_EN msgEn;
@Autowired
private Msg_CN msgCn;
@Autowired
private Msg_JP msgJp;
/**
* 参数映射
* @param languaType
* @param code
* @return
*/
public String getParameterMapByCode(Integer languaType,String code){
String msg = null;
if(null != languaType){
if(languaType == 0){//中文
msg = MapUtils.getString(msgCn.getParameterMap(), code, code);
}else if(languaType == 1){//英文
msg = MapUtils.getString(msgEn.getParameterMap(), code, code);
}else if(languaType == 2){//日语
msg = MapUtils.getString(msgJp.getParameterMap(), code, code);
}
}else{
msg = MapUtils.getString(msgJp.getParameterMap(), code, code);
}
return msg;
}
}

25
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_CN.java

@ -0,0 +1,25 @@
package com.dongjian.datacenter.admin.common.language.msg;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import com.dongjian.datacenter.admin.common.language.PropertySourceYumFactory;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@Component
@PropertySource(value = "classpath:/config/language/msg/msg_cn.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class)
@ConfigurationProperties(prefix = "msgcn")
public class Msg_CN {
private Map<String,String> parameterMap;
private Map<String,String> reportMap;
}

25
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_EN.java

@ -0,0 +1,25 @@
package com.dongjian.datacenter.admin.common.language.msg;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import com.dongjian.datacenter.admin.common.language.PropertySourceYumFactory;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@Component
@PropertySource(value = "classpath:/config/language/msg/msg_en.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class)
@ConfigurationProperties(prefix = "msgen")
public class Msg_EN {
private Map<String,String> parameterMap;
private Map<String,String> reportMap;
}

25
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/language/msg/Msg_JP.java

@ -0,0 +1,25 @@
package com.dongjian.datacenter.admin.common.language.msg;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import com.dongjian.datacenter.admin.common.language.PropertySourceYumFactory;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@Component
@PropertySource(value = "classpath:/config/language/msg/msg_jp.yml", encoding = "UTF-8", factory = PropertySourceYumFactory.class)
@ConfigurationProperties(prefix = "msgjp")
public class Msg_JP {
private Map<String,String> parameterMap;
private Map<String,String> reportMap;
}

51
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/BaseResponse.java

@ -0,0 +1,51 @@
package com.dongjian.datacenter.admin.common.response;
import io.swagger.v3.oas.annotations.media.Schema;
/**
*
* @author jwy-style
*
*/
public class BaseResponse<T> {
/**
* 返回码
*/
@Schema(description = "状态码, 0或者200表示成功",example = "0")
private int code;
/**
* 提示信息
*/
@Schema(description = "简单的提示信息",example = "服务器错误")
private String msg = "success";
public BaseResponse() {
}
public BaseResponse(int code) {
this.code = code;
}
public BaseResponse(int code, String msg) {
this.code = code;
this.msg = msg;
}
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;
}
}

401
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/PageInfo.java

@ -0,0 +1,401 @@
package com.dongjian.datacenter.admin.common.response;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageSerializable;
/**
* 对Page<E>结果进行包装
* <p/>
* 新增分页的多项属性主要参考:http://bbs.csdn.net/topics/360010907
*
* @author liuzh/abel533/isea533
* @version 3.3.0
* @since 3.2.2
* 项目地址 : http://git.oschina.net/free/Mybatis_PageHelper
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public class PageInfo<T> extends PageSerializable<T> {
public static final int DEFAULT_NAVIGATE_PAGES = 8;
public static final PageInfo EMPTY = new PageInfo(Collections.emptyList(), 0);
/**
* 当前页
*/
private int pageNum;
/**
* 每页的数量
*/
private int pageSize;
/**
* 当前页的数量
*/
private int size;
/**
* 由于startRow和endRow不常用这里说个具体的用法
* 可以在页面中"显示startRow到endRow 共size条数据"
* 当前页面第一个元素在数据库中的行号
*/
private long startRow;
/**
* 当前页面最后一个元素在数据库中的行号
*/
private long endRow;
/**
* 总页数
*/
private int pages;
/**
* 前一页
*/
private int prePage;
/**
* 下一页
*/
private int nextPage;
/**
* 是否为第一页
*/
private boolean isFirstPage = false;
/**
* 是否为最后一页
*/
private boolean isLastPage = false;
/**
* 是否有前一页
*/
private boolean hasPreviousPage = false;
/**
* 是否有下一页
*/
private boolean hasNextPage = false;
/**
* 导航页码数
*/
private int navigatePages;
/**
* 所有导航页号
*/
private int[] navigatepageNums;
/**
* 导航条上的第一页
*/
private int navigateFirstPage;
/**
* 导航条上的最后一页
*/
private int navigateLastPage;
public PageInfo() {
}
/**
* 包装Page对象
*
* @param list
*/
public PageInfo(List<? extends T> list) {
this(list, DEFAULT_NAVIGATE_PAGES);
}
/**
* 包装Page对象
*
* @param list page结果
* @param navigatePages 页码数量
*/
public PageInfo(List<? extends T> list, int navigatePages) {
super(list);
if (list instanceof Page) {
Page page = (Page) list;
this.pageNum = page.getPageNum();
this.pageSize = page.getPageSize();
this.pages = page.getPages();
this.size = page.size();
//由于结果是>startRow的,所以实际的需要+1
if (this.size == 0) {
this.startRow = 0;
this.endRow = 0;
} else {
this.startRow = page.getStartRow() + 1;
//计算实际的endRow(最后一页的时候特殊)
this.endRow = this.startRow - 1 + this.size;
}
} else if (list instanceof Collection) {
this.pageNum = 1;
this.pageSize = list.size();
this.pages = this.pageSize > 0 ? 1 : 0;
this.size = list.size();
this.startRow = 0;
this.endRow = list.size() > 0 ? list.size() - 1 : 0;
}
if (list instanceof Collection) {
calcByNavigatePages(navigatePages);
}
}
public static <T> PageInfo<T> of(List<? extends T> list) {
return new PageInfo<T>(list);
}
public static <T> PageInfo<T> of(List<? extends T> list, int navigatePages) {
return new PageInfo<T>(list, navigatePages);
}
/**
* 返回一个空的 Pageinfo 对象
*
* @return
*/
public static <T> PageInfo<T> emptyPageInfo() {
return EMPTY;
}
public void calcByNavigatePages(int navigatePages) {
setNavigatePages(navigatePages);
//计算导航页
calcNavigatepageNums();
//计算前后页,第一页,最后一页
calcPage();
//判断页面边界
judgePageBoudary();
}
/**
* 计算导航页
*/
private void calcNavigatepageNums() {
//当总页数小于或等于导航页码数时
if (pages <= navigatePages) {
navigatepageNums = new int[pages];
for (int i = 0; i < pages; i++) {
navigatepageNums[i] = i + 1;
}
} else { //当总页数大于导航页码数时
navigatepageNums = new int[navigatePages];
int startNum = pageNum - navigatePages / 2;
int endNum = pageNum + navigatePages / 2;
if (startNum < 1) {
startNum = 1;
//(最前navigatePages页
for (int i = 0; i < navigatePages; i++) {
navigatepageNums[i] = startNum++;
}
} else if (endNum > pages) {
endNum = pages;
//最后navigatePages页
for (int i = navigatePages - 1; i >= 0; i--) {
navigatepageNums[i] = endNum--;
}
} else {
//所有中间页
for (int i = 0; i < navigatePages; i++) {
navigatepageNums[i] = startNum++;
}
}
}
}
/**
* 计算前后页第一页最后一页
*/
private void calcPage() {
if (navigatepageNums != null && navigatepageNums.length > 0) {
navigateFirstPage = navigatepageNums[0];
navigateLastPage = navigatepageNums[navigatepageNums.length - 1];
if (pageNum > 1) {
prePage = pageNum - 1;
}
if (pageNum < pages) {
nextPage = pageNum + 1;
}
}
}
/**
* 判定页面边界
*/
private void judgePageBoudary() {
isFirstPage = pageNum == 1;
isLastPage = pageNum == pages || pages == 0;
hasPreviousPage = pageNum > 1;
hasNextPage = pageNum < pages;
}
/**
* 是否包含内容
*/
public boolean hasContent() {
return this.size > 0;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public long getStartRow() {
return startRow;
}
public void setStartRow(long startRow) {
this.startRow = startRow;
}
public long getEndRow() {
return endRow;
}
public void setEndRow(long endRow) {
this.endRow = endRow;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public int getPrePage() {
return prePage;
}
public void setPrePage(int prePage) {
this.prePage = prePage;
}
public int getNextPage() {
return nextPage;
}
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
public boolean isIsFirstPage() {
return isFirstPage;
}
public void setIsFirstPage(boolean isFirstPage) {
this.isFirstPage = isFirstPage;
}
public boolean isIsLastPage() {
return isLastPage;
}
public void setIsLastPage(boolean isLastPage) {
this.isLastPage = isLastPage;
}
public boolean isHasPreviousPage() {
return hasPreviousPage;
}
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
public boolean isHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
public int getNavigatePages() {
return navigatePages;
}
public void setNavigatePages(int navigatePages) {
this.navigatePages = navigatePages;
}
public int[] getNavigatepageNums() {
return navigatepageNums;
}
public void setNavigatepageNums(int[] navigatepageNums) {
this.navigatepageNums = navigatepageNums;
}
public int getNavigateFirstPage() {
return navigateFirstPage;
}
public int getNavigateLastPage() {
return navigateLastPage;
}
public void setNavigateFirstPage(int navigateFirstPage) {
this.navigateFirstPage = navigateFirstPage;
}
public void setNavigateLastPage(int navigateLastPage) {
this.navigateLastPage = navigateLastPage;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("PageInfo{");
sb.append("pageNum=").append(pageNum);
sb.append(", pageSize=").append(pageSize);
sb.append(", size=").append(size);
sb.append(", startRow=").append(startRow);
sb.append(", endRow=").append(endRow);
sb.append(", total=").append(total);
sb.append(", pages=").append(pages);
sb.append(", list=").append(list);
sb.append(", prePage=").append(prePage);
sb.append(", nextPage=").append(nextPage);
sb.append(", isFirstPage=").append(isFirstPage);
sb.append(", isLastPage=").append(isLastPage);
sb.append(", hasPreviousPage=").append(hasPreviousPage);
sb.append(", hasNextPage=").append(hasNextPage);
sb.append(", navigatePages=").append(navigatePages);
sb.append(", navigateFirstPage=").append(navigateFirstPage);
sb.append(", navigateLastPage=").append(navigateLastPage);
sb.append(", navigatepageNums=");
if (navigatepageNums == null) {
sb.append("null");
} else {
sb.append('[');
for (int i = 0; i < navigatepageNums.length; ++i) {
sb.append(i == 0 ? "" : ", ").append(navigatepageNums[i]);
}
sb.append(']');
}
sb.append('}');
return sb.toString();
}
}

66
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/PageResponse.java

@ -0,0 +1,66 @@
package com.dongjian.datacenter.admin.common.response;
import com.github.pagehelper.PageInfo;
import java.util.Map;
/**
*
* @author jwy-style
*
* @param <T>
*/
public class PageResponse<T> extends BaseResponse<T>{
/**
* 对象信息
*/
private T data;
private Map<String,String> errorMap;
public PageResponse() {
}
public PageResponse(int code) {
super(code);
}
public PageResponse(int code, String msg) {
super(code, msg);
}
public PageResponse(int code,String msg,Map<String,String> errorMap){
super(code, msg);
this.errorMap = errorMap;
}
public static PageResponse success(Object data){
PageResponse pageResponse = new PageResponse();
pageResponse.setData((PageInfo) data);
pageResponse.setCode(ResponseCode.SUCCESS);
pageResponse.setMsg("success");
return pageResponse;
}
public Map<String, String> getErrorMap() {
return errorMap;
}
public void setErrorMap(Map<String, String> errorMap) {
this.errorMap = errorMap;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

32
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/ResponseCode.java

@ -0,0 +1,32 @@
package com.dongjian.datacenter.admin.common.response;
/**
*
* @author jwy-style
*
*/
public class ResponseCode {
/** 成功 */
public static final int OK = 0;
/**
* 请求已成功请求所希望的响应头或数据体将随此响应返回
*/
public static final int SUCCESS = 200;
//鉴权不通过
public static final int AUTHORIZE_FAILED = 401;
//服务器内部错误
public static final int SERVER_ERROR = 500;
public static final String SERVER_ERROR_MSG = "service error";
/** 系统错误 */
public static final int SYSTEM_ERROR = 20000;
//
public static final int MSG_ERROR = 20001;
public static final int MSG_DATA_NULL_ERROR = 20002;
public static final int MSG_DATA_ERROR = 20003;
}

104
dongjian-center-admin-common/src/main/java/com/dongjian/datacenter/admin/common/response/SimpleDataResponse.java

@ -0,0 +1,104 @@
package com.dongjian.datacenter.admin.common.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Map;
/**
*
* @author jwy-style
*
* @param <T>
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SimpleDataResponse<T> extends BaseResponse<T> {
/**
* 单个对象
*/
@Schema(description = "返回的数据",example = "object")
private T data;
/**
* The parameters Error map.
*/
@Schema(description = "复杂的提示信息",example = "{\"name\":\"长度过长\",\"age\":\"年龄太大\",\"weight\":\"体重超标\"}")
private Map<String, String> errorMap;
public SimpleDataResponse() {
super();
}
public SimpleDataResponse(int code) {
super(code);
}
public SimpleDataResponse(int code, String msg) {
super(code, msg);
}
/**
* 响应结果携带错误Map
* @param code
* @param msg
* @param errorMap
*/
public SimpleDataResponse(int code, String msg, Map<String, String> errorMap) {
this(code, msg);
this.errorMap = errorMap;
}
/**
* 成功响应
* @return
*/
public static SimpleDataResponse success(){
return new SimpleDataResponse(ResponseCode.SUCCESS,"Success");
}
/**
* 多条数据成功响应
* @param rows
* @return
*/
public static SimpleDataResponse success(int rows){
return new SimpleDataResponse(ResponseCode.SUCCESS,"Success: "+rows);
}
/**
* 成功响应携带数据对象返回
* @param data
* @return
*/
public static SimpleDataResponse success(Object data){
SimpleDataResponse comm = success();
comm.setData(data);
return comm;
}
public static SimpleDataResponse fail(int code,String message){
return new SimpleDataResponse(code,message);
}
public static SimpleDataResponse fail(int code,String message,Object data){
SimpleDataResponse simpleDataResponse= new SimpleDataResponse(code,message);
simpleDataResponse.setData(data);
return simpleDataResponse;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Map<String, String> getErrorMap() {
return errorMap;
}
public void setErrorMap(Map<String, String> errorMap) {
this.errorMap = errorMap;
}
}

60
dongjian-center-admin-common/src/main/resources/config/language/msg/msg_cn.yml

@ -0,0 +1,60 @@
msgcn:
parameterMap:
serviceError: 内部服务错误
tokenError: 接口鉴权失败
excelEmpty: 表格为空
lineNum: 第{0}行:
paramsFormatError: 参数格式错误
verifCodeExpired: 验证码过期
verifCodeError: 验证码错误
accountExpired: 该账号已过期
pwdError: 密码错误
userNotExist: 用户不存在
noOperationAuth: 无操作权限
projectNameHasExisted: 项目名称已存在
projectNameDoesNotExist: 项目名称不存在
buildingNameHasExisted: 楼宇名称已存在
buildingNameDoesNotExist: 楼宇名称不存在
floorNameHasExisted: 楼层名称已存在
floorNameDoesNotExist: 楼层名称不存在
buildingNotFound: 不存在该楼宇
fbNotSameCompany: 需与楼宇归属于同一企业
spaceNameHasExisted: 房间名称已存在
floorNotFound: 不存在该楼层
rfNotSameCompany: 需与楼层归属于同一企业
assetNameHasExisted: 资产名称已存在
assetSymbolHasExisted: 资产记号已存在
assetNameDoesNotExist: 资产名称不存在
assetSymbolDoesNotExist: 资产记号不存在
spaceNotFound: 不存在该房间
faNotSameCompany: 需与房间归属于同一企业
bindedDevice: 绑定了设备
deviceTypeNotExist: 设备类型不存在
excelBuildingLineDuplicate: 表格内存在相同的数据
dbBuildingDuplicate: 平台已存在此楼宇
dbFloorDuplicate: 平台已存在此楼层
dbSpaceDuplicate: 平台已存在此房间
dbAssetDuplicate: 平台已存在此资产
excelCompanyNameIsNull: 需填写企业名称
excelBuildingNameIsNull: 需填写楼宇
excelFloorNameIsNull: 需填写楼层
excelSpaceNameIsNull: 需填写房间
excelSpaceOrFloorNameIsNull: 需填写楼层和房间
excelCompanyNameNotExist: 平台不存在此企业名称
userOrEmailNotExist: 用户名或邮箱不存在
companyNameHasExisted: 平台已存在此企业
taowaComapny: 不可使用下级企业作为父企业
hasSubsidiary: 删除的企业拥有下级企业,需先处理下级企业
roleNameExist: 角色名已存在
roleHasBinded: 角色已绑定用户,请先解绑再删除
loginNameOrEmailHasExisted: 用户名或邮箱已被使用
mailAddUserPwdSubject: 新建账号密码
mailAddUserPwdContentAdmin: 'アカウント <u>{0}</u> のパスワードは <span style="text-transform: none;"><u>{1}</u></span> お忘れにならないようにお願いします。<br/><br/>ログインWebアドレス:<u>{2}</u>'
mailAddUserPwdContent: '{0}<br/><br/>このたびは、データ管理プラットフォームへのご登録、誠にありがとうございます。<br/><br/>下記の通り、アカウントが発行されましたのでご案内いたします。<br/><br/>-------------------------------------------------<br/>ユーザー名(ID):<u>{1}</u><br/>初期パスワード:<span style="text-transform: none;"><u>{2}</u></span><br/>-------------------------------------------------<br/><br/>ログインはこちらから:<br/>【2D3DWebログインURL】:<u>{3}</u><br/>【データ管理プラットフォームURL】:<u>{4}</u><br/><br/>ご不明な点がございましたら、お気軽にサポートまでお問い合わせください。<br/><br/>-------------------------------<br/>株式会社テクサー<br/>サポート窓口: support@techsor.co.jp<br/>-------------------------------'
mailResetUserPwdSubject: 重置账号密码
pwdFormatError: 密码组成必须包含数字、英文字母、特殊符号(~!@#$%^&*)且大于等于12位
oldPwdError: 旧密码错误
newPwdSameOld: 新密码不得与旧密码相同
companyLimit: 最多可创建15个企业
consecutiveLoginFail: 登录失败次数过多,请等待{0}分{1}秒后再登录
loginFailCount: 已登录失败{0}次,剩余尝试登录次数:{1}

60
dongjian-center-admin-common/src/main/resources/config/language/msg/msg_en.yml

@ -0,0 +1,60 @@
msgen:
parameterMap:
serviceError: Internal service error.
tokenError: API authentication failed.
excelEmpty: The spreadsheet is empty.
lineNum: "Lines {0}:"
paramsFormatError: Parameter format error.
verifCodeExpired: Verification code expired.
verifCodeError: Verification code error.
accountExpired: The account has expired.
pwdError: Password error.
userNotExist: User does not exist.
noOperationAuth: No operation permission.
projectNameHasExisted: Project name already exists.
projectNameDoesNotExist: Project name does not exist.
buildingNameHasExisted: Building name already exists.
buildingNameDoesNotExist: Building name does not exist.
floorNameHasExisted: Floor name already exists.
floorNameDoesNotExist: Floor name does not exist.
buildingNotFound: Building not found.
fbNotSameCompany: Must belong to the same company as the building.
spaceNameHasExisted: Room name already exists.
floorNotFound: Floor not found.
rfNotSameCompany: Must belong to the same company as the floor.
assetNameHasExisted: Asset name already exists.
assetSymbolHasExisted: Asset symbol already exists.
assetNameDoesNotExist: Asset name does not exist.
assetSymbolDoesNotExist: 资产记号不存在
spaceNotFound: Room not found.
faNotSameCompany: Must belong to the same company as the room.
bindedDevice: Device is bound.
deviceTypeNotExist: Device type does not exist.
excelBuildingLineDuplicate: Duplicate data exists in the spreadsheet.
dbBuildingDuplicate: This building already exists on the platform.
dbFloorDuplicate: 平台已存在此楼层
dbSpaceDuplicate: 平台已存在此房间
dbAssetDuplicate: 平台已存在此资产
excelCompanyNameIsNull: Company name needs to be filled out.
excelBuildingNameIsNull: Building name needs to be filled out.
excelFloorNameIsNull: 需填写楼层
excelSpaceNameIsNull: 需填写房间
excelSpaceOrFloorNameIsNull: 需填写楼层和房间
excelCompanyNameNotExist: The platform does not have this company name.
userOrEmailNotExist: 用户名或邮箱不存在
companyNameHasExisted: 平台已存在此企业
taowaComapny: 不可使用下级企业作为父企业
hasSubsidiary: 删除的企业拥有下级企业,需先处理下级企业
roleNameExist: 角色名已存在
roleHasBinded: 角色已绑定用户,请先解绑再删除
loginNameOrEmailHasExisted: 用户名或邮箱已被使用
mailAddUserPwdSubject: 新建账号密码
mailAddUserPwdContentAdmin: 'アカウント <u>{0}</u> のパスワードは <span style="text-transform: none;"><u>{1}</u></span> お忘れにならないようにお願いします。<br/><br/>ログインWebアドレス:<u>{2}</u>'
mailAddUserPwdContent: '{0}<br/><br/>このたびは、データ管理プラットフォームへのご登録、誠にありがとうございます。<br/><br/>下記の通り、アカウントが発行されましたのでご案内いたします。<br/><br/>-------------------------------------------------<br/>ユーザー名(ID):<u>{1}</u><br/>初期パスワード:<span style="text-transform: none;"><u>{2}</u></span><br/>-------------------------------------------------<br/><br/>ログインはこちらから:<br/>【2D3DWebログインURL】:<u>{3}</u><br/>【データ管理プラットフォームURL】:<u>{4}</u><br/><br/>ご不明な点がございましたら、お気軽にサポートまでお問い合わせください。<br/><br/>-------------------------------<br/>株式会社テクサー<br/>サポート窓口: support@techsor.co.jp<br/>-------------------------------'
mailResetUserPwdSubject: 重置账号密码
pwdFormatError: 密码组成必须包含数字、英文字母、特殊符号(~!@#$%^&*)且大于等于12位
oldPwdError: 旧密码错误
newPwdSameOld: 新密码不得与旧密码相同
companyLimit: 最多可创建15个企业
consecutiveLoginFail: Too many failed login attempts. Please wait {0} minute(s) and {1} second(s) before trying again.
loginFailCount: Login failed {0} times. Remaining login attempts:{1}.

60
dongjian-center-admin-common/src/main/resources/config/language/msg/msg_jp.yml

@ -0,0 +1,60 @@
msgjp:
parameterMap:
serviceError: 内部サービスのエラー
tokenError: インターフェイスの認証に失敗
excelEmpty: フォームが空になっている
lineNum: 行{0}:
paramsFormatError: パラメータのフォーマットエラー
verifCodeExpired: 確認コード期限切れ
verifCodeError: 確認コードエラー
accountExpired: アカウントの有効期限が切れている
pwdError: パスワードエラー
userNotExist: ユーザーが存在しない
noOperationAuth: 操作権限なし
projectNameHasExisted: プロジェクト名がすでにある
projectNameDoesNotExist: プロジェクト名がない
buildingNameHasExisted: 該当ビル名がすでにある
buildingNameDoesNotExist: 該当ビル名がない
floorNameHasExisted: 該当フロア名がすでにある
floorNameDoesNotExist: 該当フロア名がない
buildingNotFound: 該当ビルがない
fbNotSameCompany: ビルと同じ会社に所属してください
spaceNameHasExisted: 該当部屋名がすでにある
floorNotFound: 該当フロア名がない
rfNotSameCompany: フロアと同じ会社に所属してください
assetNameHasExisted: 該当資産名がすでにある
assetSymbolHasExisted: 記号はすでに存在します
assetNameDoesNotExist: 該当資産名がない
assetSymbolDoesNotExist: 資産記号が存在しません
spaceNotFound: 該当部屋がない
faNotSameCompany: 部屋と同じ会社に所属してください
bindedDevice: デバイスと関連付け
deviceTypeNotExist: デバイスタイプがない
excelBuildingLineDuplicate: テーブルに同じデータがある
dbBuildingDuplicate: プラットフォームにすでに該当ビルがない
dbFloorDuplicate: プラットフォームには既にこのフロアが存在しています。
dbSpaceDuplicate: プラットフォームには既にこのスペースが存在しています。
dbAssetDuplicate: プラットフォームには既にこのアセットが存在しています。
excelCompanyNameIsNull: 会社名を入力してください
excelBuildingNameIsNull: ビルを入力してください
excelFloorNameIsNull: フロア名を入力してください。
excelSpaceNameIsNull: スペース名を入力してください。
excelSpaceOrFloorNameIsNull: フロア名とスペース名を入力してください。
excelCompanyNameNotExist: プラットフォーム上に該当会社名はない
userOrEmailNotExist: ユーザーが存在しません
companyNameHasExisted: 会社はすでにプラットフォーム上に存在する
taowaComapny: 下位の会社を親会社として利用することは不可
hasSubsidiary: 削除対象の会社には下位の会社があるので、先に下位の会社を対応してください
roleNameExist: 役割名が既に登録済み
roleHasBinded: 役割はユーザーにバインドされている ので、削除する前にバインドを解除してください
loginNameOrEmailHasExisted: ユーザー名またはメールボックスはすでに使用されています
mailAddUserPwdSubject: 新規アカウント・パスワードの作成
mailAddUserPwdContentAdmin: 'アカウント <u>{0}</u> のパスワードは <span style="text-transform: none;"><u>{1}</u></span> お忘れにならないようにお願いします。<br/><br/>ログインWebアドレス:<u>{2}</u>'
mailAddUserPwdContent: '{0}<br/><br/>このたびは、データ管理プラットフォームへのご登録、誠にありがとうございます。<br/><br/>下記の通り、アカウントが発行されましたのでご案内いたします。<br/><br/>-------------------------------------------------<br/>ユーザー名(ID):<u>{1}</u><br/>初期パスワード:<span style="text-transform: none;"><u>{2}</u></span><br/>-------------------------------------------------<br/><br/>ログインはこちらから:<br/>【2D3DWebログインURL】:<u>{3}</u><br/>【データ管理プラットフォームURL】:<u>{4}</u><br/><br/>ご不明な点がございましたら、お気軽にサポートまでお問い合わせください。<br/><br/>-------------------------------<br/>株式会社テクサー<br/>サポート窓口: support@techsor.co.jp<br/>-------------------------------'
mailResetUserPwdSubject: アカウント・パスワードのリセット
pwdFormatError: パスワードの構成には、数字、アルファベット、特殊文字(~!@#$%^&*) で、12桁以上
oldPwdError: 旧パスワードエラー
newPwdSameOld: 注:旧パスワードと同じものを使用しないでください
companyLimit: 最大15のエンタープライズを作成可能
consecutiveLoginFail: ログインの失敗が多すぎます。{0}分{1}秒待ってから再度ログインしてください。
loginFailCount: ログインに{0}回失敗しました。残りの試行回数:{1}回。

15
dongjian-center-admin-controller/.gitignore

@ -0,0 +1,15 @@
/target/
/logs/
/.idea/
*.iml
*.bak
*.log
/.settings/
*.project
*.classpath
*.factorypath
*.springBeans
/.apt_generated/
/.externalToolBuilders/
/bin/
application-*.properties

11
dongjian-center-admin-controller/buildPush-prod.sh

@ -0,0 +1,11 @@
aws configure set aws_access_key_id AKIAVRXFMB43TOELSROK
aws configure set aws_secret_access_key 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
aws configure set default.region ap-northeast-1
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com
docker build -t 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-admin:latest\
--build-arg JAR_FILE=target/dongjian-center-admin-controller-0.0.1-SNAPSHOT.jar \
--build-arg LIB_DIR=target/lib \
--build-arg CONFIG_DIR=target/config \
.
docker push 381659385655.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-admin:latest

11
dongjian-center-admin-controller/buildPush-staging.sh

@ -0,0 +1,11 @@
aws configure set aws_access_key_id AKIA5OFH5OOZPCXZIRUQ
aws configure set aws_secret_access_key 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
aws configure set default.region ap-northeast-1
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com
docker build -t 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-admin:latest\
--build-arg JAR_FILE=target/dongjian-center-admin-controller-0.0.1-SNAPSHOT.jar \
--build-arg LIB_DIR=target/lib \
--build-arg CONFIG_DIR=target/config \
.
docker push 923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/tokyo-build-admin:latest

70
dongjian-center-admin-controller/dockerfile

@ -0,0 +1,70 @@
#FROM openjdk:8-jre-alpine
#FROM amazon-corretto-8
#FROM amazoncorretto:11
# 使用Ubuntu 20.04 LTS作为基础镜像
# FROM ubuntu:20.04
FROM registry.ap-northeast-1.aliyuncs.com/southwave/ubuntu2004-template:latest
# 设置系统的默认编码方式为 UTF-8
ENV LANG=en_US.UTF-8
ENV LC_CTYPE=zh_CN.UTF-8
# 设置环境变量,避免交互式安装
ENV DEBIAN_FRONTEND=noninteractive
# 更新APT软件包索引并安装必要的软件包
RUN apt-get update && \
apt-get install -y \
curl \
unzip \
vim \
fontconfig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 安装Terraform
RUN curl -fsSLk https://releases.hashicorp.com/terraform/1.7.5/terraform_1.7.5_linux_amd64.zip -o /tmp/terraform.zip && \
unzip /tmp/terraform.zip -d /usr/local/bin/ && \
rm /tmp/terraform.zip
# 安装Amazon Corretto 11 JDK
RUN curl -fsSLk https://corretto.aws/downloads/resources/11.0.22.7.1/amazon-corretto-11.0.22.7.1-linux-x64.tar.gz -o /tmp/amazon-corretto-11.tar.gz && \
mkdir /usr/lib/jvm/ && \
tar -xzvf /tmp/amazon-corretto-11.tar.gz -C /usr/lib/jvm/ && \
rm /tmp/amazon-corretto-11.tar.gz
# 设置JAVA_HOME环境变量
ENV JAVA_HOME=/usr/lib/jvm/amazon-corretto-11.0.22.7.1-linux-x64
ENV PATH=$JAVA_HOME/bin:$PATH
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
# 打印Terraform版本
RUN terraform --version
# 打印Java版本
RUN java -version
WORKDIR /home/data-center-admin
#EXPOSE 20008
# 设置时区
#RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ARG JAR_FILE
ARG LIB_DIR
ARG CONFIG_DIR
ARG AURORA_TERRAFORM
ARG JVM_OPTS
COPY ${JAR_FILE} app.jar
COPY ${LIB_DIR} lib
COPY ${CONFIG_DIR} config
COPY ${AURORA_TERRAFORM} aurora_terraform
#ENTRYPOINT ["java", "${JVM_OPTS}", "-jar","app.jar"]
ENTRYPOINT java ${JVM_OPTS} -jar app.jar

545
dongjian-center-admin-controller/pom.xml

@ -0,0 +1,545 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dongjian-center-admin-controller</artifactId>
<name>dongjian-center-admin-controller</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aws.ecr.repository>tokyo-build-admin</aws.ecr.repository>
<aws.ecr.tag>latest</aws.ecr.tag>
<aws.ecr.region>ap-northeast-1</aws.ecr.region>
<aws.ecr.registry.test>923770123186.dkr.ecr.ap-northeast-1.amazonaws.com</aws.ecr.registry.test>
<aws.access.key.test>AKIA5OFH5OOZHM3U3KX4</aws.access.key.test>
<aws.secret.access.key.test>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</aws.secret.access.key.test>
<aws.ecr.registry.production>381659385655.dkr.ecr.ap-northeast-1.amazonaws.com</aws.ecr.registry.production>
<aws.access.key.production>AKIAVRXFMB43XVQ3GXAL</aws.access.key.production>
<aws.secret.access.key.production>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</aws.secret.access.key.production>
</properties>
<dependencies>
<dependency>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.techsor</groupId>
<artifactId>dongjian-center-admin-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>only-package</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<!-- 项目的打包配置 -->
<plugins>
<!-- 自定义打zip包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>dongjian-center-admin</finalName>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>docker-package</id>
<build>
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 -->
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.5</version>
<configuration>
<from>
<![CDATA[
<!--
这里先登录【docker login --username=409950420@qq.com registry.ap-northeast-1.aliyuncs.com】,
然后【docker pull registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest】到本地,
再docker://使用本地镜像
-->
]]>
<image>docker://registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest</image>
</from>
<to>
<image>registry.cn-shanghai.aliyuncs.com/clouddog/datacenter-admin:${aws.ecr.tag}</image>
</to>
<container>
<workingDirectory>/home/dongjian-center-admin</workingDirectory>
<environment>
<TZ>Asia/Tokyo</TZ>
</environment>
<entrypoint>
<entrypoint>java</entrypoint>
<entrypoint>-jar</entrypoint>
<entrypoint>${project.build.finalName}.jar</entrypoint>
</entrypoint>
</container>
<extraDirectories>
<paths>
<path>
<from>${project.build.directory}</from>
<includes>${project.build.finalName}.jar</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>lib/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>config/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>aurora_terraform/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
</paths>
<permissions>
<permission>
<file>/home/dongjian-center-admin/lib</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/config</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/aurora_terraform</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<!-- 本地,使用dockerBuild目标而不是build -->
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>docker-aliyun</id>
<build>
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 -->
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.5</version>
<configuration>
<from>
<![CDATA[
<!--
这里先登录【docker login --username=409950420@qq.com registry.ap-northeast-1.aliyuncs.com】,
然后【docker pull registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest】到本地,
再docker://使用本地镜像
-->
]]>
<image>docker://registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest</image>
</from>
<to>
<image>${aws.ecr.registry.test}/${aws.ecr.repository}:${aws.ecr.tag}</image>
</to>
<container>
<workingDirectory>/home/dongjian-center-admin</workingDirectory>
<environment>
<TZ>Asia/Tokyo</TZ>
</environment>
<entrypoint>
<entrypoint>java</entrypoint>
<entrypoint>-jar</entrypoint>
<entrypoint>${project.build.finalName}.jar</entrypoint>
</entrypoint>
</container>
<extraDirectories>
<paths>
<path>
<from>${project.build.directory}</from>
<includes>${project.build.finalName}.jar</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>lib/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>config/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>aurora_terraform/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
</paths>
<permissions>
<permission>
<file>/home/dongjian-center-admin/lib</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/config</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/aurora_terraform</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<!-- 本地,使用dockerBuild目标而不是build -->
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- maven-antrun-plugin执行推送aws ecr的命令 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<!--放在package阶段后面执行-->
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Run AWS ECR login command using Ant tasks -->
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="docker login --username=409950420@qq.com registry.cn-shanghai.aliyuncs.com --password=Youqu48bnb1." />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="docker push registry.cn-shanghai.aliyuncs.com/clouddog/datacenter-admin:${aws.ecr.tag}" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>docker-test</id>
<build>
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 -->
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.5</version>
<configuration>
<from>
<![CDATA[
<!--
这里先登录【docker login --username=409950420@qq.com registry.ap-northeast-1.aliyuncs.com】,
然后【docker pull registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest】到本地,
再docker://使用本地镜像
-->
]]>
<image>docker://registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest</image>
</from>
<to>
<image>${aws.ecr.registry.test}/${aws.ecr.repository}:${aws.ecr.tag}</image>
</to>
<container>
<workingDirectory>/home/dongjian-center-admin</workingDirectory>
<environment>
<TZ>Asia/Tokyo</TZ>
</environment>
<entrypoint>
<entrypoint>java</entrypoint>
<entrypoint>-jar</entrypoint>
<entrypoint>${project.build.finalName}.jar</entrypoint>
</entrypoint>
</container>
<extraDirectories>
<paths>
<path>
<from>${project.build.directory}</from>
<includes>${project.build.finalName}.jar</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>lib/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>config/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>aurora_terraform/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
</paths>
<permissions>
<permission>
<file>/home/dongjian-center-admin/lib</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/config</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/aurora_terraform</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<!-- 本地,使用dockerBuild目标而不是build -->
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- maven-antrun-plugin执行推送aws ecr的命令 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<!--放在package阶段后面执行-->
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Run AWS ECR login command using Ant tasks -->
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set aws_access_key_id ${aws.access.key.test}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set aws_secret_access_key ${aws.secret.access.key.test}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set default.region ${aws.ecr.region}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set default.output text" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws ecr get-login-password --region ${aws.ecr.region} | docker login --username AWS --password-stdin ${aws.ecr.registry.test}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="docker push ${aws.ecr.registry.test}/${aws.ecr.repository}:${aws.ecr.tag}" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>docker-production</id>
<build>
<!-- 先用dockerfile-maven-plugin构建镜像,然后maven-antrun-plugin执行推送aws ecr的命令 -->
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.5</version>
<configuration>
<from>
<![CDATA[
<!--
这里先登录【docker login --username=409950420@qq.com registry.ap-northeast-1.aliyuncs.com】,
然后【docker pull registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest】到本地,
再docker://使用本地镜像
-->
]]>
<image>docker://registry.ap-northeast-1.aliyuncs.com/southwave/jdk17-template:latest</image>
</from>
<to>
<image>${aws.ecr.registry.production}/${aws.ecr.repository}:${aws.ecr.tag}</image>
</to>
<container>
<workingDirectory>/home/dongjian-center-admin</workingDirectory>
<environment>
<TZ>Asia/Tokyo</TZ>
</environment>
<entrypoint>
<entrypoint>java</entrypoint>
<entrypoint>-jar</entrypoint>
<entrypoint>${project.build.finalName}.jar</entrypoint>
</entrypoint>
</container>
<extraDirectories>
<paths>
<path>
<from>${project.build.directory}</from>
<includes>${project.build.finalName}.jar</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>lib/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>config/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
<path>
<from>${project.build.directory}</from>
<includes>aurora_terraform/**</includes>
<into>/home/dongjian-center-admin/</into>
</path>
</paths>
<permissions>
<permission>
<file>/home/dongjian-center-admin/lib</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/config</file>
<mode>755</mode>
</permission>
<permission>
<file>/home/dongjian-center-admin/aurora_terraform</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- maven-antrun-plugin执行推送aws ecr的命令 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<!--放在package阶段后面执行-->
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Run AWS ECR login command using Ant tasks -->
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set aws_access_key_id ${aws.access.key.production}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set aws_secret_access_key ${aws.secret.access.key.production}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set default.region ${aws.ecr.region}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws configure set default.output text" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="aws ecr get-login-password --region ${aws.ecr.region} | docker login --username AWS --password-stdin ${aws.ecr.registry.production}" />
</exec>
<exec executable="cmd" osfamily="windows">
<arg value="/c" />
<arg value="docker push ${aws.ecr.registry.production}/${aws.ecr.repository}:${aws.ecr.tag}" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

20
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/DongjianAdminApplication.java

@ -0,0 +1,20 @@
package com.dongjian.datacenter.admin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
//@ComponentScan({"com.dongjian.datacenter.admin"})
@ServletComponentScan
@EnableAsync
@EnableScheduling
public class DongjianAdminApplication {
public static void main(String[] args) {
SpringApplication.run(DongjianAdminApplication.class, args);
}
}

56
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/ApiConfig.java

@ -0,0 +1,56 @@
package com.dongjian.datacenter.admin.configurator;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver;
import org.springframework.mobile.device.DeviceResolverHandlerInterceptor;
import org.springframework.util.unit.DataSize;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessApiInterceptor;
import jakarta.servlet.MultipartConfigElement;
import java.io.File;
import java.util.List;
@Configuration
public class ApiConfig implements WebMvcConfigurer {
@Bean
public AccessApiInterceptor accessApiInterceptor(){
return new AccessApiInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(accessApiInterceptor());
}
@Bean
public DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver() {
return new DeviceHandlerMethodArgumentResolver();
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(deviceHandlerMethodArgumentResolver());
}
@Bean
public MultipartConfigElement multipartConfigElement() {
String path = System.getProperty("user.dir")+"/tmp";
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(DataSize.ofMegabytes(20L));
File tmpFile = new File(path);
if (!tmpFile.exists()) {
tmpFile.mkdirs();
}
factory.setLocation(path);
return factory.createMultipartConfig();
}
}

38
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/CorsConfigurer.java

@ -0,0 +1,38 @@
package com.dongjian.datacenter.admin.configurator;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* 跨域配置
* @author jwy
* @time 2022-5-12 17:54:43
*/
@Configuration
public class CorsConfigurer {
@Value("${crosxss.origin:*}")
private String corsOrigin;
@Bean
public FilterRegistrationBean corsFilter() {
List<String> allowedOriginPatterns = new ArrayList<String>();
allowedOriginPatterns.add(corsOrigin);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.setAllowedOriginPatterns(allowedOriginPatterns);
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
bean.setOrder(0);
return bean;
}
}

78
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/CrosXssFilter.java

@ -0,0 +1,78 @@
package com.dongjian.datacenter.admin.configurator;
import java.io.IOException;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import java.util.UUID;
import org.jboss.logging.MDC;
@WebFilter
public class CrosXssFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(CrosXssFilter.class);
@Value("${crosxss.filter.disable:false}")
private boolean disable;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
try {
MDC.put("processNo", UUID.randomUUID().toString().replace("-", ""));
request.setCharacterEncoding("utf-8");
// response.setContentType("text/html;charset=utf-8");
if (disable) {
chain.doFilter(request, response);
} else {
//跨域设置
if (response instanceof HttpServletResponse) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
//禁用浏览器缓存
httpServletResponse.setHeader("Cache-Control", "no-store");
//禁止被IFrame嵌套
httpServletResponse.setHeader("X-Frame-Options", "deny");
//安全性配置
httpServletResponse.setHeader("X-XSS-Protection", "1; mode=block");
httpServletResponse.setHeader("X-Content-Type-Options", "nosniff");
httpServletResponse.setHeader("Referrer-Policy", "origin");
}
ServletRequest requestWrapper = null;
if(request instanceof HttpServletRequest) {
requestWrapper = new RequestWrapper((HttpServletRequest) request);
}
if(requestWrapper == null) {
chain.doFilter(request, response);
} else {
chain.doFilter(requestWrapper, response);
}
}
} finally {
// 避免线程泄漏
MDC.clear();
}
}
@Override
public void destroy() {
}
}

92
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/RequestWrapper.java

@ -0,0 +1,92 @@
package com.dongjian.datacenter.admin.configurator;
import jakarta.servlet.ReadListener;
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
public class RequestWrapper extends HttpServletRequestWrapper {
private static final Logger logger = LoggerFactory.getLogger(HttpServletRequestWrapper.class);
private final String body;
public RequestWrapper(HttpServletRequest request) {
super(request);
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = null;
InputStream inputStream = null;
try {
inputStream = request.getInputStream();
if (inputStream != null) {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
char[] charBuffer = new char[128];
int bytesRead = -1;
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
stringBuilder.append(charBuffer, 0, bytesRead);
}
} else {
stringBuilder.append("");
}
} catch (IOException ex) {
logger.error("RequestWrapper读取流错误", ex);
} finally {
if (inputStream != null) {
try {
inputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
if (bufferedReader != null) {
try {
bufferedReader.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
body = stringBuilder.toString();
}
@Override
public ServletInputStream getInputStream() throws IOException {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
ServletInputStream servletInputStream = new ServletInputStream() {
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return false;
}
@Override
public void setReadListener(ReadListener readListener) {
}
@Override
public int read() throws IOException {
return byteArrayInputStream.read();
}
};
return servletInputStream;
}
@Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(this.getInputStream()));
}
public String getBody() {
return this.body;
}
}

73
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/interceptor/AccessApiInterceptor.java

@ -0,0 +1,73 @@
package com.dongjian.datacenter.admin.configurator.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.dongjian.datacenter.admin.common.response.ResponseCode;
import com.dongjian.datacenter.admin.service.AccountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
public class AccessApiInterceptor implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(AccessApiInterceptor.class);
@Value("${user.login.keytimeout}")
private long keytimeout;
@Autowired
private AccountService accountService;
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if(handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Class<?> tClass = handlerMethod.getBeanType();
AccessRequired annotation = tClass.getAnnotation(AccessRequired.class);
if (annotation == null) {
Method method = handlerMethod.getMethod();
annotation = method.getAnnotation(AccessRequired.class);
}
try {
if (annotation != null) {
String loginName = request.getHeader("LoginName");
String accessToken = request.getHeader("AccessToken");
String userId = request.getHeader("UserId");
String companyId = request.getHeader("CompanyId");
String languageType = request.getHeader("LanguageType");
response.setContentType("application/json;charset=utf-8");
String URI = request.getRequestURI();
logger.info("===============请求的URI :" + URI + " ===============");
JSONObject jsonObject = new JSONObject();
boolean result = accountService.accessAuth(loginName, companyId, userId, accessToken, languageType, jsonObject, keytimeout);
if(!result) {
response.getWriter().print(jsonObject.toString());
}
return result;
}
} catch (Exception e) {
logger.error("Error from AccessApiInterceptor!", e);
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", ResponseCode.SERVER_ERROR);
jsonObject.put("msg", "service error");
response.getWriter().print(jsonObject.toString());
return false;
}
// 没有注解通过拦截
return true;
}else if(handler instanceof ResourceHttpRequestHandler) {//资源文件不拦截
return true;
}
return false;
}
}

10
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/configurator/interceptor/AccessRequired.java

@ -0,0 +1,10 @@
package com.dongjian.datacenter.admin.configurator.interceptor;
import java.lang.annotation.*;
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AccessRequired {
}

103
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/AccountController.java

@ -0,0 +1,103 @@
package com.dongjian.datacenter.admin.controller;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mobile.device.Device;
import org.springframework.web.bind.annotation.*;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessRequired;
import com.dongjian.datacenter.admin.dto.account.CacheUserData;
import com.dongjian.datacenter.admin.dto.account.LoginParam;
import com.dongjian.datacenter.admin.service.AccountService;
import com.dongjian.datacenter.admin.service.captcha.CaptchaService;
import com.dongjian.datacenter.admin.service.captcha.CaptchaVO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* 账户管理
* @author jwy-style
*
*/
@RestController
@RequestMapping("/account")
@Tag(name = "AccountController",description = "账号登录/登出、获取验证码接口")
public class AccountController {
@Autowired
private AccountService accountService;
@Autowired
private DefaultKaptcha producer;
@Autowired
private CaptchaService captchaService;
@Operation(summary = "用户登录")
@RequestMapping(value = "/login", method = RequestMethod.POST)
public SimpleDataResponse<CacheUserData> login(@RequestBody LoginParam loginParam,
@Parameter(name="LanguageType", description="Language Type 0: Chinese, 1: English, 2: Japanese", required=true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType,
HttpServletRequest request,
HttpServletResponse response,
Device device) {
return accountService.login(loginParam,device,LanguageType,request,response);
}
/**
* 用户退出登录
* @param user_name
* @param access_token
* @return
*/
@AccessRequired
@Operation(summary = "用户退出")
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public SimpleDataResponse logout( @Parameter(name="LoginName",description="Login Name",required=true) @RequestHeader(required=true) String LoginName,
@Parameter(name="AccessToken",description="Authentication Token",required=true) @RequestHeader(required=true) String AccessToken,
@Parameter(name="UserId",description="User ID",required=true) @RequestHeader(required=true) Long UserId,
@Parameter(name="CompanyId",description="Company ID",required=false) @RequestHeader(required=false) Long CompanyId,
@Parameter(name="LanguageType", description="Language Type 0: Chinese, 1: English, 2: Japanese", required=true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType) {
return accountService.logout(AccessToken,CompanyId,LoginName,UserId);
}
/**
* 获取验证码
* @param user_name
* @param access_token
* @return
*/
@Operation(summary = "获取登录验证码")
@RequestMapping(value = "/getCaptcha", method = RequestMethod.GET )
public SimpleDataResponse<CaptchaVO> getCaptcha() throws IOException {
// 生成文字验证码
String content = producer.createText();
// 生成图片验证码
ByteArrayOutputStream outputStream = null;
BufferedImage image = producer.createImage(content);
outputStream = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", outputStream);
// 对字节数组Base64编码
// BASE64Encoder encoder = new BASE64Encoder();
String str = "data:image/jpeg;base64,";
String base64Img = str + Base64.encodeBase64String(outputStream.toByteArray()).replace("\n", "").replace("\r", "");
CaptchaVO captchaVO = captchaService.cacheCaptcha(content);
captchaVO.setBase64Img(base64Img);
return SimpleDataResponse.success(captchaVO);
}
}

81
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/CommonController.java

@ -0,0 +1,81 @@
package com.dongjian.datacenter.admin.controller;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.service.CommonService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
/**
*
* @author jwy-style
*
*/
//@ApiIgnore
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
@RequestMapping("/common") //http请求路径映射
@Tag(name = "CommonController",description = "公共接口")
@SuppressWarnings("unchecked")
public class CommonController{
private static Logger logger = LoggerFactory.getLogger(CommonController.class);
@Autowired
private CommonService commonService;
@Hidden
@Operation(summary = "接收Lambda测试数据")
@RequestMapping(value = "/testReceiveLambdaData",method = RequestMethod.POST)
public SimpleDataResponse testReceiveLambdaData(@RequestBody JSONObject jsonObj){
logger.info("testReceiveLambdaData接收数据--{}", jsonObj.toString());
return SimpleDataResponse.success();
}
@Hidden
@Operation(summary = "检测apikey是否有效")
@RequestMapping(value = "/checkApikey",method = RequestMethod.GET)
public SimpleDataResponse checkApikey(
@Parameter(name = "apikey", description = "API key value", required = true) @RequestParam String apikey){
return commonService.checkApikey(apikey);
}
@Hidden
@Operation(summary = "初始化企业对应数据库")
@RequestMapping(value = "/initDatabase/{companyId}",method = RequestMethod.GET)
public SimpleDataResponse initDatabase(
@PathVariable Long companyId
){
return commonService.initDatabase(companyId);
}
@Hidden
@Operation(summary = "初始化企业对应aurora")
@RequestMapping(value = "/initAurora/{companyId}",method = RequestMethod.GET)
public SimpleDataResponse initAurora(
@PathVariable Long companyId
){
return commonService.initAurora(companyId);
}
@Hidden
@Operation(summary = "销毁企业对应aurora")
@RequestMapping(value = "/destroyAurora/{companyId}",method = RequestMethod.GET)
public SimpleDataResponse destroyAurora(
@PathVariable Long companyId
){
return commonService.destroyAurora(companyId);
}
}

138
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/CompanyController.java

@ -0,0 +1,138 @@
package com.dongjian.datacenter.admin.controller;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dongjian.datacenter.admin.common.exception.BusinessException;
import com.dongjian.datacenter.admin.common.response.PageInfo;
import com.dongjian.datacenter.admin.common.response.PageResponse;
import com.dongjian.datacenter.admin.common.response.ResponseCode;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessRequired;
import com.dongjian.datacenter.admin.dto.company.CompanySearchParams;
import com.dongjian.datacenter.admin.dto.company.DeleteCompanyParams;
import com.dongjian.datacenter.admin.dto.company.OptCompanyParams;
import com.dongjian.datacenter.admin.vo.company.CompanyPageDTO;
import com.dongjian.datacenter.admin.vo.TreeMenusDTO;
import com.dongjian.datacenter.admin.service.CompanyService;
/**
*
* @author jwy-style
*
*/
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
//@AccessRequired //注解标识是否需要验证token
@RequestMapping("/company") //http请求路径映射
@Tag(name = "CompanyController",description = "企业管理的相关接口")
@SuppressWarnings("unchecked")
public class CompanyController {
private static Logger logger = LoggerFactory.getLogger(CompanyController.class);
@Autowired
private CompanyService companyService;
@AccessRequired
@Operation(summary = "添加企业")
@RequestMapping(value = "/add",method = RequestMethod.POST)
public SimpleDataResponse add(
@RequestBody OptCompanyParams optCompanyParams,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return companyService.add(optCompanyParams, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "编辑企业")
@RequestMapping(value = "/edit",method = RequestMethod.POST)
public SimpleDataResponse edit(
@RequestBody OptCompanyParams optCompanyParams,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType) {
return companyService.edit(optCompanyParams, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "删除企业")
@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
public SimpleDataResponse batchDelete(
@RequestBody DeleteCompanyParams deleteCompanyParams,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return companyService.batchDelete(deleteCompanyParams, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "获取当前登录用户下的企业菜单树")
@RequestMapping(value = "/getCompanyTree",method = RequestMethod.GET)
public SimpleDataResponse<List<TreeMenusDTO>> getCompanyTree(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return companyService.getCompanyTree(CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "获取企业列表")
@RequestMapping(value = "/getListPage",method = RequestMethod.GET)
public PageResponse<PageInfo<CompanyPageDTO>> getListPage(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
// @ApiParam(name="LoginCompanyId",value="登录用户的企业ID",required=false,defaultValue = "1") @RequestHeader(required=false) Long LoginCompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType,
@Parameter(name="UTCOffset",description="格林威治时间与本地时间的差值,单位是分钟,比如东八区是 -480",required=true,schema = @Schema(defaultValue = "-480")) @RequestHeader(required=true) Integer UTCOffset,
CompanySearchParams pageSearchParam
) throws BusinessException {
pageSearchParam.setUserId(UserId);
// if (1 == pageSearchParam.getSearchType()) {
// pageSearchParam.setCompanyId(LoginCompanyId);
// } else if (2 == pageSearchParam.getSearchType()) {
// pageSearchParam.setCompanyId(CompanyId);
// }
PageResponse<PageInfo<CompanyPageDTO>> pageResponse = new PageResponse<PageInfo<CompanyPageDTO>>();
try{
pageResponse.setData(companyService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType, UTCOffset));
pageResponse.setCode(ResponseCode.SUCCESS);
pageResponse.setMsg("success");
}catch (Exception e){
logger.error("查询列表报错",e);
pageResponse.setCode(ResponseCode.SERVER_ERROR);
pageResponse.setMsg("service error");
}
return pageResponse;
}
@Operation(summary = "创建大阪区资源")
@RequestMapping(value = "/initAurora/osaka",method = RequestMethod.GET)
public SimpleDataResponse osakaInitAurora(){
return companyService.osakaInitAurora();
}
}

35
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/HealthController.java

@ -0,0 +1,35 @@
package com.dongjian.datacenter.admin.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Properties;
@RestController
public class HealthController {
@GetMapping("/healthcheck")
public String health(){
return "ok";
}
@GetMapping("/version")
public String getVersion() throws IOException {
Properties properties = new Properties();
Reader in = new InputStreamReader(this.getClass().getResourceAsStream("/config/version.properties"),"utf-8");
BufferedReader bufferedReader = new BufferedReader(in);
properties.load(bufferedReader);
String version=properties.getProperty("project.latest.version");
String content = properties.getProperty(version);
JSONObject jsonObject = new JSONObject();
jsonObject.put("version", version);
jsonObject.put("content", content);
return jsonObject.toString();
}
}

110
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/ProjectController.java

@ -0,0 +1,110 @@
package com.dongjian.datacenter.admin.controller;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dongjian.datacenter.admin.common.exception.BusinessException;
import com.dongjian.datacenter.admin.common.response.PageInfo;
import com.dongjian.datacenter.admin.common.response.PageResponse;
import com.dongjian.datacenter.admin.common.response.ResponseCode;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessRequired;
import com.dongjian.datacenter.admin.dto.project.DeleteProjectParams;
import com.dongjian.datacenter.admin.dto.project.OptProjectParams;
import com.dongjian.datacenter.admin.dto.project.ProjectSearchParams;
import com.dongjian.datacenter.admin.service.ProjectService;
import com.dongjian.datacenter.admin.vo.project.ProjectPageVO;
/**
*
* @author jwy-style
*
*/
@Hidden
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
@AccessRequired //注解标识是否需要验证登录token,放在这表示整个类的接口都要鉴权,也可以注释掉放在单独的接口上对指定接口鉴权
@RequestMapping("/project") //http请求路径映射
@Tag(name = "ProjectController", description = "项目管理模块的相关接口")
@SuppressWarnings("unchecked")
public class ProjectController {
private static Logger logger = LoggerFactory.getLogger(ProjectController.class);
// @Autowired
// private ProjectService projectService;
//
//// @AccessRequired
// @Operation(summary = "添加项目")
// @RequestMapping(value = "/add",method = RequestMethod.POST)
// public SimpleDataResponse add(
// @RequestBody OptProjectParams optProjectParams,
// @ApiParam(name="LoginName",value="登录名",required=true,defaultValue = "admin") @RequestHeader(required=true) String LoginName,
// @ApiParam(name="AccessToken",value="鉴权token",required=true) @RequestHeader(required=true) String AccessToken,
// @ApiParam(name="UserId",value="用户ID",required=true,defaultValue = "1") @RequestHeader(required=true) Long UserId,
// @ApiParam(name="CompanyId",value="用户所属企业ID",required=false,defaultValue = "1") @RequestHeader(required=false) Long CompanyId,
// @ApiParam(name="LanguageType",value="语言类型 0:中文 1:英文 2:日文",required=true,defaultValue = "2") @RequestHeader(required=true) Integer LanguageType){
// return projectService.add(optProjectParams, UserId, CompanyId, LanguageType);
// }
//
// @Operation(summary = "编辑项目")
// @RequestMapping(value = "/edit",method = RequestMethod.POST)
// public SimpleDataResponse edit(
// @RequestBody OptProjectParams optProjectParams,
// @ApiParam(name="LoginName",value="登录名",required=true,defaultValue = "admin") @RequestHeader(required=true) String LoginName,
// @ApiParam(name="AccessToken",value="鉴权token",required=true) @RequestHeader(required=true) String AccessToken,
// @ApiParam(name="UserId",value="用户ID",required=true,defaultValue = "1") @RequestHeader(required=true) Long UserId,
// @ApiParam(name="CompanyId",value="用户所属企业ID",required=false,defaultValue = "1") @RequestHeader(required=false) Long CompanyId,
// @ApiParam(name="LanguageType",value="语言类型 0:中文 1:英文 2:日文",required=true,defaultValue = "2") @RequestHeader(required=true) Integer LanguageType){
// return projectService.edit(optProjectParams, UserId, CompanyId, LanguageType);
// }
//
// @Operation(summary = "删除项目")
// @RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
// public SimpleDataResponse batchDelete(
// @RequestBody DeleteProjectParams deleteProjectParams,
// @ApiParam(name="LoginName",value="登录名",required=true,defaultValue = "admin") @RequestHeader(required=true) String LoginName,
// @ApiParam(name="AccessToken",value="鉴权token",required=true) @RequestHeader(required=true) String AccessToken,
// @ApiParam(name="UserId",value="用户ID",required=true,defaultValue = "1") @RequestHeader(required=true) Long UserId,
// @ApiParam(name="CompanyId",value="用户所属企业ID",required=false,defaultValue = "1") @RequestHeader(required=false) Long CompanyId,
// @ApiParam(name="LanguageType",value="语言类型 0:中文 1:英文 2:日文",required=true,defaultValue = "2") @RequestHeader(required=true) Integer LanguageType){
// return projectService.batchDelete(deleteProjectParams, UserId, CompanyId, LanguageType);
// }
//
// @Operation(summary = "获取项目列表")
// @RequestMapping(value = "/getListPage",method = RequestMethod.GET)
// public PageResponse<PageInfo<ProjectPageVO>> getListPage(
// @ApiParam(name="LoginName",value="登录名",required=true,defaultValue = "admin") @RequestHeader(required=true) String LoginName,
// @ApiParam(name="AccessToken",value="鉴权token",required=true) @RequestHeader(required=true) String AccessToken,
// @ApiParam(name="UserId",value="用户ID",required=true,defaultValue = "1") @RequestHeader(required=true) Long UserId,
// @ApiParam(name="CompanyId",value="用户所属企业ID",required=false,defaultValue = "1") @RequestHeader(required=false) Long CompanyId,
// @ApiParam(name="LanguageType",value="语言类型 0:中文 1:英文 2:日文",required=true,defaultValue = "2") @RequestHeader(required=true) Integer LanguageType,
// @ApiParam(name="UTCOffset",value="格林威治时间与本地时间的差值,单位是分钟,比如东八区是 -480",required=true,defaultValue = "-480") @RequestHeader(required=true) Integer UTCOffset,
// ProjectSearchParams pageSearchParam
// ) throws BusinessException {
//
// pageSearchParam.setUserId(UserId);
//
// PageResponse<PageInfo<ProjectPageVO>> pageResponse = new PageResponse<PageInfo<ProjectPageVO>>();
// try{
// pageResponse.setData(projectService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType, UTCOffset));
// pageResponse.setCode(ResponseCode.SUCCESS);
// pageResponse.setMsg("success");
// }catch (Exception e){
// logger.error("查询列表报错",e);
// pageResponse.setCode(ResponseCode.SERVER_ERROR);
// pageResponse.setMsg("service error");
// }
// return pageResponse;
// }
}

132
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/RoleController.java

@ -0,0 +1,132 @@
package com.dongjian.datacenter.admin.controller;
import com.dongjian.datacenter.admin.common.exception.BusinessException;
import com.dongjian.datacenter.admin.common.response.PageInfo;
import com.dongjian.datacenter.admin.common.response.PageResponse;
import com.dongjian.datacenter.admin.common.response.ResponseCode;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessRequired;
import com.dongjian.datacenter.admin.dto.role.DeleteRoleParam;
import com.dongjian.datacenter.admin.dto.role.OptRoleParam;
import com.dongjian.datacenter.admin.dto.role.PageSearchParam;
import com.dongjian.datacenter.admin.vo.TreeMenusDTO;
import com.dongjian.datacenter.admin.vo.role.RolePageDTO;
import com.dongjian.datacenter.admin.service.RoleService;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
*
* @author jwy-style
*
*/
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
@AccessRequired //注解标识是否需要验证token
@RequestMapping("/role") //http请求路径映射
@Tag(name = "RoleController",description = "角色权限的相关接口")
@SuppressWarnings("unchecked")
public class RoleController {
private static Logger logger = LoggerFactory.getLogger(RoleController.class);
@Autowired
private RoleService roleService;
@Operation(summary = "添加角色")
@RequestMapping(value = "/add",method = RequestMethod.POST)
public SimpleDataResponse add(
@RequestBody OptRoleParam optRoleParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.add(optRoleParam, CompanyId, UserId, LanguageType);
}
@Operation(summary = "编辑角色")
@RequestMapping(value = "/edit",method = RequestMethod.POST)
public SimpleDataResponse edit(
@RequestBody OptRoleParam optRoleParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.edit(optRoleParam, CompanyId, UserId, LanguageType);
}
@Operation(summary = "删除角色")
@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
public SimpleDataResponse batchDelete(
@RequestBody DeleteRoleParam deleteRoleParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.batchDelete(deleteRoleParam, CompanyId, UserId, LanguageType);
}
@Operation(summary = "获取角色列表")
@RequestMapping(value = "/getListPage",method = RequestMethod.GET)
public PageResponse<PageInfo<RolePageDTO>> getListPage(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType,
PageSearchParam pageSearchParam
) throws BusinessException {
pageSearchParam.setUserId(UserId);
// pageSearchParam.setCompanyId(CompanyId);
PageResponse<PageInfo<RolePageDTO>> pageResponse = new PageResponse<PageInfo<RolePageDTO>>();
try{
pageResponse.setData(roleService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType));
pageResponse.setCode(ResponseCode.SUCCESS);
pageResponse.setMsg("success");
}catch (Exception e){
logger.error("查询列表报错",e);
pageResponse.setCode(ResponseCode.SERVER_ERROR);
pageResponse.setMsg("service error");
}
return pageResponse;
}
@Operation(summary = "获取当前登录用户拥有的权限菜单树")
@RequestMapping(value = "/getOwnMenuIds",method = RequestMethod.GET)
public SimpleDataResponse<List<TreeMenusDTO>> getOwnMenuIds(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getOwnMenuIds(CompanyId, UserId, LanguageType);
}
@Operation(summary = "获取对应角色拥有的权限菜单ID")
@RequestMapping(value = "/getMenuIdsByRoleId",method = RequestMethod.GET)
public SimpleDataResponse<String> getMenuIdsByRoleId(
@Parameter(name="roleId",description="角色ID",required=true, schema = @Schema(defaultValue = "28")) @RequestParam Long roleId,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getMenuIdsByRoleId(roleId, CompanyId, UserId, LanguageType);
}
}

54
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/SysEnvController.java

@ -0,0 +1,54 @@
package com.dongjian.datacenter.admin.controller;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.dto.sysenv.SysEnvEditParam;
import com.dongjian.datacenter.admin.dto.sysenv.SysEnvQueryParam;
import com.dongjian.datacenter.admin.service.sysenv.SysEnvService;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
//@AccessRequired
@RequestMapping("/sys/env")
@Tag(name = "SysEnvController",description = "")
@Slf4j
public class SysEnvController {
@Autowired
private SysEnvService sysEnvService;
@Operation(summary = "edit", description = "")
@PostMapping(value = "/edit")
public SimpleDataResponse edit(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required = true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required = true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required = true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required = false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required = true) Integer LanguageType,
@Parameter(name = "UTCOffset", description = "Offset between GMT and local time in minutes, e.g., -480 for GMT+8") @RequestHeader(required = true) Integer UTCOffset,
@RequestBody SysEnvEditParam param
){
return sysEnvService.edit(param, UserId, CompanyId, LanguageType);
}
@Operation(summary = "query", description = "")
@PostMapping(value = "/query")
public SimpleDataResponse query(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required = true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required = true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required = true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required = false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required = true) Integer LanguageType,
@Parameter(name = "UTCOffset", description = "Offset between GMT and local time in minutes, e.g., -480 for GMT+8") @RequestHeader(required = true) Integer UTCOffset,
@RequestBody SysEnvQueryParam param
){
return SimpleDataResponse.success(sysEnvService.getValueByKey(param.getEnvKey()));
}
}

153
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/controller/UserController.java

@ -0,0 +1,153 @@
package com.dongjian.datacenter.admin.controller;
import com.dongjian.datacenter.admin.common.exception.BusinessException;
import com.dongjian.datacenter.admin.common.response.PageInfo;
import com.dongjian.datacenter.admin.common.response.PageResponse;
import com.dongjian.datacenter.admin.common.response.ResponseCode;
import com.dongjian.datacenter.admin.common.response.SimpleDataResponse;
import com.dongjian.datacenter.admin.configurator.interceptor.AccessRequired;
import com.dongjian.datacenter.admin.dto.user.DeleteUserParam;
import com.dongjian.datacenter.admin.dto.user.ModifyPassword;
import com.dongjian.datacenter.admin.dto.user.OptUserParam;
import com.dongjian.datacenter.admin.dto.user.PageSearchParam;
import com.dongjian.datacenter.admin.dto.user.ResetPassword;
import com.dongjian.datacenter.admin.dto.user.SwitchMfaBind;
import com.dongjian.datacenter.admin.service.UserService;
import com.dongjian.datacenter.admin.vo.user.UserPageDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
*
* @author jwy-style
*
*/
@RestController//代表返回的是json格式的数据,这个注解是Spring4之后新加的注解
//@AccessRequired //注解标识是否需要验证token
@RequestMapping("/user") //http请求路径映射
@Tag(name = "UserController",description = "用户管理的相关接口")
@SuppressWarnings("unchecked")
public class UserController {
private static Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
private UserService userService;
@AccessRequired
@Operation(summary = "添加用户")
@RequestMapping(value = "/add",method = RequestMethod.POST)
public SimpleDataResponse add(
@RequestBody OptUserParam optUserParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return userService.add(optUserParam, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "编辑用户")
@RequestMapping(value = "/edit",method = RequestMethod.POST)
public SimpleDataResponse edit(
@RequestBody OptUserParam optUserParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return userService.edit(optUserParam, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "删除用户")
@RequestMapping(value = "/batchDelete",method = RequestMethod.POST)
public SimpleDataResponse batchDelete(
@RequestBody DeleteUserParam deleteUserParam,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return userService.batchDelete(deleteUserParam, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "重置密码")
@RequestMapping(value = "/batchResetPassword",method = RequestMethod.POST)
public SimpleDataResponse batchResetPassword(
@RequestBody ResetPassword resetPassword,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return userService.batchResetPassword(resetPassword, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "修改密码")
@RequestMapping(value = "/modifyPassword",method = RequestMethod.POST)
public SimpleDataResponse modifyPassword(
@RequestBody ModifyPassword modifyPassword,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType
) {
return userService.modifyPassword(modifyPassword, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "解绑MFA设备")
@RequestMapping(value = "/unbindMfa",method = RequestMethod.POST)
public SimpleDataResponse unbindMfa(
@RequestBody SwitchMfaBind switchMfaBind,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType
) {
return userService.unbindMfa(switchMfaBind, CompanyId, UserId, LanguageType);
}
@AccessRequired
@Operation(summary = "获取用户列表")
@RequestMapping(value = "/getListPage",method = RequestMethod.GET)
public PageResponse<PageInfo<UserPageDTO>> getListPage(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=false) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType,
PageSearchParam pageSearchParam
) throws BusinessException {
pageSearchParam.setUserId(UserId);
// pageSearchParam.setCompanyId(CompanyId);
PageResponse<PageInfo<UserPageDTO>> pageResponse = new PageResponse<PageInfo<UserPageDTO>>();
try{
pageResponse.setData(userService.getListPage(pageSearchParam, CompanyId, UserId, LanguageType));
pageResponse.setCode(ResponseCode.SUCCESS);
pageResponse.setMsg("success");
}catch (Exception e){
logger.error("查询列表报错",e);
pageResponse.setCode(ResponseCode.SERVER_ERROR);
pageResponse.setMsg("service error");
}
return pageResponse;
}
}

50
dongjian-center-admin-controller/src/main/java/com/dongjian/datacenter/admin/swagger/SwaggerConfig.java

@ -0,0 +1,50 @@
//package com.dongjian.datacenter.admin.swagger;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Profile;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Contact;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
///**
// * http://127.0.0.1:20002/swagger-ui.html
//* @author 江武元
// */
//@Configuration
//@EnableSwagger2
//public class SwaggerConfig {
//
// @Value("${api.enable:false}")
// private boolean enable;
//
//// @Profile({"dev","stg"})
// @Bean
// public Docket webApiConfig(){
// return new Docket(DocumentationType.SWAGGER_2)
// .groupName("webApi")
// .apiInfo(webApiInfo())
// .select()
// //配置显示所有的URL
// .paths(PathSelectors.any())
// .build()
// .enable(enable);
// }
//
// private ApiInfo webApiInfo(){
// return new ApiInfoBuilder()
// //文档标题
// .title("接口文档")
// //文档描述
// .description("接口文档")
// //文档版本
// .version("1.0")
// .build();
// }
//}
//

59
dongjian-center-admin-controller/src/main/resources/assembly.xml

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<!-- 最终打包文件的后缀,格式为 ${fileName}-bin -->
<id>dongjian-center-admin</id>
<!-- 最终打包成一个用于发布的zip文件 -->
<formats>
<format>zip</format>
</formats>
<!-- 文件配置 -->
<fileSets>
<!-- 把项目自己编译出来根目录下的jar文件,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来的jar文件夹下的jar文件,去除第三方jar,打包进zip文件的根目录 -->
<fileSet>
<directory>${project.build.directory}/jar</directory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>lib/*.jar</exclude>
</excludes>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<!-- 把项目自己编译出来的lib文件夹下的jar文件,打包进zip文件的lib目录 -->
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<!-- 把编译出来的config文件夹,去除application.properties,打包进zip文件的config目录 -->
<fileSet>
<directory>${project.build.directory}/config</directory>
<outputDirectory>/config</outputDirectory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
</fileSet>
<!-- 把编译出来的sql文件夹,打包进zip文件的sql目录 -->
<fileSet>
<directory>${project.build.directory}/sql</directory>
<outputDirectory>/sql</outputDirectory>
</fileSet>
</fileSets>
</assembly>

175
dongjian-center-admin-controller/src/main/resources/aurora_terraform/main.tf

@ -0,0 +1,175 @@
provider "aws" {
region = "ap-northeast-1"
# shared_config_files = [var.aws_access_config_path]
# shared_credentials_files = [var.aws_access_credentials_path]
# profile = "tkbuild-stg"
access_key = var.access_key
secret_key = var.secret_key
}
# modules vpc
# VPC和subnet信息
module "network" {
source = "./modules/network"
vpc_name = "${var.project_name}-vpc"
}
# security group
module "securitygroup" {
source = "./modules/securitygroup"
vpc_id = module.network.vpc_id
project_name = var.project_name
}
# redis和mysql
module "rds_redis" {
source = "./modules/rds"
project_name = var.project_name
db_name = "tokyo-building-db"
}
# aurora
module "Aurora" {
source = "./modules/aurora"
project_name = var.project_name
company_name = var.company_name
# RDS共用subnet gp
# aurora-subnet-group = module.rds_redis.rds_subnet_gp
aurora_sg = [module.securitygroup.security_group_sg_db_id]
}
# # Active MQ
#
# module "ActiveMQ" {
# source = "./modules/mq"
# project_name = var.company_name
# subnet_mq_ids = module.network.protected_subnet_ids
# sg_mq = module.securitygroup.security_group_mq_db_id
# }
# albinternal albadmin alb nlb
module "alb_elb" {
source = "./modules/alb"
vpc_id = module.network.vpc_id
# project_name = company_name for one company
project_name = var.project_name
company_name = var.company_name
sg_alb_id = [module.securitygroup.security_group_sg_alb_id]
sg_internal_alb_id = [module.securitygroup.security_group_sg_internal_alb_id]
sub_public_ids = module.network.public_subnet_ids
sub_protect_ids = module.network.protected_subnet_ids
}
# alb添加dns解析
#
# # alb ${company_name}.kr-sensor.net
# # admin alb ${company_name}-admin.kr-sensor.net
# module "route53" {
# source = "./modules/dns"
# company_name = var.company_name
# admin_alb_name = module.alb_elb.alb_admin_domain_name
# admin_alb_zone_id = module.alb_elb.alb_admin_zone_id
# alb_name = module.alb_elb.alb_domain_name
# alb_zone_id = module.alb_elb.alb_zone_id
# }
# Image信息
module "ecr" {
source = "./modules/ecr"
repo_business_web = "tokyo-build-business"
repo_business_back = "tokyo-build-business-web"
repo_receiver = "tokyo-build-receiver"
repo_sender = "tokyo-build-sender"
repo_mqtt = "tokyo-build-mqtt"
repo_adminback = "tokyo-build-admin"
repo_adminweb = "tokyo-build-admin-web"
}
# senderrecever
module "ecs" {
source = "./modules/ecs_fargate"
# project_name = var.company_name when one company
project_name = var.project_name
company_name = var.company_name
autoscaling_subnet = module.network.protected_subnet_ids
sgapp_id = [ module.securitygroup.security_group_sg_app_id ]
business_name = module.ecr.business_name
business_image = module.ecr.business_uri
business_web_name = module.ecr.business-web_name
business_web_image = module.ecr.business-web_uri
sender_name = module.ecr.sender_name
sender_image = module.ecr.sender_uri
roid2Url = "https://api.public-api.kanri-roid.app/api/public/v1/targets/{targetId}/monitoring-status"
roidAlarmUrl = "https://api.public-api.kanri-roid.app/api/public/v1/problem-reports/alarm"
roidAlarmCancelUrl = "https://api.public-api.kanri-roid.app/api/public/v1/problem-reports/return-to-normal"
roidAuthorization = var.roidAuthorization
roid2Authorization = var.roid2Authorization
queryPushInfoUrl = "iothub-web.ttkdatatechbuild.com"
#kinesis stream
mqttNormalTopic = module.kinesis.aws_kinesis_stream_name
mqtt_name = module.ecr.mqtt_name
mqtt_image = module.ecr.mqtt_uri
adminback_name = module.ecr.adminback_name
adminback_image = module.ecr.adminback_uri
adminWeb_name = module.ecr.adminweb_name
adminWeb_image = module.ecr.adminweb_uri
receiver_name = module.ecr.receiver_name
receiver_image = module.ecr.receiver_uri
# redis mysql
redisHost = module.rds_redis.redis_address
redisDatabase = "0"
alarmRedisDatabase = var.alarmRedisDatabase
datasourceDNS = module.rds_redis.rds_address
# alb
receiver_tg_8200_arn = module.alb_elb.alb_8200_arn
# internal alb
sender_tg_8201_arn = module.alb_elb.alb_inter_8201_arn
sender_tg_8201_arn_suffix = module.alb_elb.alb_inter_8201_arn_suffix
dataCenterReceiverTargetUrl = module.alb_elb.alb_internal_dns
}
# kinesis stream
module "kinesis" {
source = "./modules/kinesis"
company_name = var.company_name
}
module "lambda" {
source = "./modules/lambda"
company_name = var.company_name
AURORA_USERNAME = "techsor"
AURORA_PASSWORD = "Abc#123456xyz"
AURORA_URL = module.Aurora.cluster_endpoint
AWS_ACCESS = var.access_key
AWS_SECRET = var.secret_key
subnet_ids = module.network.protected_subnet_ids
sggroup_ids = [module.securitygroup.security_group_sg_app_id]
aws_kinesis_stream_name = module.kinesis.aws_kinesis_stream_name
}
module "eventbridge_pipe" {
source = "./modules/eventbridge"
company_name = var.company_name
aws_kinesis_stream_arn = module.kinesis.aws_kinesis_stream_arn
aws_lambda_arn = module.lambda.aws_lambda_arn
}
module "glue_job" {
source = "./modules/glue_job"
project_name = var.project_name
company_name = var.company_name
aurora_endpoint = module.Aurora.cluster_endpoint
}
# teffaform init
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target
# terraform refresh

90
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/main.tf

@ -0,0 +1,90 @@
# Create target group 8200
resource "aws_lb_target_group" "TG-TCP-8200" {
name = "prod-${var.company_name}-tg-8200"
port = 8200
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id
# wait before changing the state of a deregistering target from draining to unused.
deregistration_delay = 60
health_check {
interval = 30
path = "/healthcheck"
port = 8200
protocol = "HTTP"
timeout = 5
unhealthy_threshold = 2
matcher = 200
}
}
# Create ALB
resource "aws_lb" "ALB-prod-alb" {
name = "${var.company_name}-alb"
internal = false
load_balancer_type = "application"
security_groups = var.sg_alb_id
subnets = var.sub_public_ids
enable_deletion_protection = false
}
# Create ALB listener
resource "aws_lb_listener" "ALB-prod-alb-listener-8200" {
load_balancer_arn = aws_lb.ALB-prod-alb.arn
port = 8200
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.TG-TCP-8200.arn
}
}
########################
# Create target group 8201
resource "aws_lb_target_group" "TG-TCP-8201" {
name = "prod-${var.company_name}-tg-8201"
port = 8201
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id
# wait before changing the state of a deregistering target from draining to unused.
deregistration_delay = 60
health_check {
interval = 30
path = "/healthcheck"
port = 8201
protocol = "HTTP"
timeout = 5
unhealthy_threshold = 2
matcher = 200
}
}
# Create internal ALB
resource "aws_lb" "ALB-prod-alb-internal" {
name = "${var.company_name}-alb-internal"
internal = true
load_balancer_type = "application"
security_groups = var.sg_internal_alb_id
subnets = var.sub_protect_ids
enable_deletion_protection = false
}
# Create ALB listener
resource "aws_lb_listener" "ALB-prod-alb-listener-8201" {
load_balancer_arn = aws_lb.ALB-prod-alb-internal.arn
port = 8201
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.TG-TCP-8201.arn
}
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

19
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/output.tf

@ -0,0 +1,19 @@
output "alb_8200_arn" {
value = aws_lb_target_group.TG-TCP-8200.arn
}
output "alb_inter_8201_arn" {
value = aws_lb_target_group.TG-TCP-8201.arn
}
output "alb_inter_8201_arn_suffix" {
value = aws_lb_target_group.TG-TCP-8201.arn_suffix
}
output "alb_internal_dns" {
value = aws_lb.ALB-prod-alb-internal.dns_name
}
output "alb_dns" {
value = aws_lb.ALB-prod-alb.dns_name
}

31
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/alb/valiables.tf

@ -0,0 +1,31 @@
variable "project_name" {
type = string
}
variable "company_name" {
type = string
}
variable "id" {
type = list(string)
default = ["01", "02", "03"]
}
variable "vpc_id" {
type = string
}
variable "sg_alb_id" {
type = list(string)
}
variable "sg_internal_alb_id" {
type = list(string)
}
variable "sub_public_ids" {
type = list(string)
}
variable "sub_protect_ids" {
type = list(string)
}

63
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/main.tf

@ -0,0 +1,63 @@
# resource "aws_kms_key" "example" {
# description = "AWS KMS Key to encrypt Database Activity Stream"
# }
# resource "aws_db_subnet_group" "rds-subnet-group" {
# name = var.db_name
# description = "rds subnet group for ${var.db_name}"
# # subnet_ids = [var.aws_subnet.private[0].id, aws_subnet.private[1].id]
# subnet_ids = var.aurora_sub_public_id
# # subnet_ids = var.aurora_sub_public_id
# }
# data "aws_db_subnet_group" "rds-subnet-group" {
# }
# third-dev-subnet-gp
# subnet
data "aws_db_subnet_group" "rds-subnet-group" {
name = "${var.project_name}-db-subnet-gp"
}
# tokyo-build-prod-db-subnet-gp
resource "aws_rds_cluster" "sensor" {
cluster_identifier = "${var.company_name}-aurora-cluster"
engine = "aurora-mysql"
engine_mode = "provisioned"
engine_version = var.aurora_engine_version
master_username = var.aurora_username
# master_user_secret_kms_key_id = aws_kms_key.example.key_id
# manage_master_user_password = true
master_password = var.aurora_passwd
availability_zones = var.availability_zones
backup_retention_period = 3
# preferred_backup_window = "00:00-01:00"
skip_final_snapshot = true
vpc_security_group_ids = var.aurora_sg
db_cluster_parameter_group_name = "tokyo-build-prod-db-cluster-param-gp"
db_instance_parameter_group_name = "tokyo-build-prod-db-param-gp"
# RDS共用
# db_subnet_group_name = var.aurora-subnet-group
db_subnet_group_name = data.aws_db_subnet_group.rds-subnet-group.name
}
resource "aws_rds_cluster_instance" "sensor" {
count = 1
identifier = "${var.company_name}-aurora-instance"
cluster_identifier = aws_rds_cluster.sensor.id
instance_class = "db.r6g.large"
engine = aws_rds_cluster.sensor.engine
engine_version = aws_rds_cluster.sensor.engine_version
# publicly_accessible = true
# db_subnet_group_name = aws_db_subnet_group.rds-subnet-group.name
db_subnet_group_name = data.aws_db_subnet_group.rds-subnet-group.name
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

7
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/output.tf

@ -0,0 +1,7 @@
output "cluster_endpoint" {
value = aws_rds_cluster.sensor.endpoint
}
output "reader_endpoint" {
value = aws_rds_cluster.sensor.reader_endpoint
}

44
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/aurora/valiables.tf

@ -0,0 +1,44 @@
variable "project_name" {
type = string
}
variable "company_name" {
type = string
}
# variable "aurora_sub_public_id" {
# type = list(string)
# }
variable "db_name" {
type = string
default = "se"
}
variable "availability_zones" {
type = list(string)
default = ["ap-northeast-1a", "ap-northeast-1c"]
}
variable "aurora_engine_version" {
type = string
default = "8.0.mysql_aurora.3.04.1"
}
variable "aurora_username" {
type = string
default = "techsor"
}
variable "aurora_passwd" {
type = string
default = "Abc#123456xyz"
}
variable "aurora_sg" {
type = list(string)
}
# variable "aurora-subnet-group" {
# type = string
# }
# variable "aurora_zone" {
# type = string
# default = "ap-northeast-1a"
# }

28
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/main.tf

@ -0,0 +1,28 @@
data "aws_route53_zone" "selected" {
name = var.domain_name
private_zone = false
}
resource "aws_route53_record" "company-dns" {
zone_id = data.aws_route53_zone.selected.zone_id
name = "${var.company_name}.${data.aws_route53_zone.selected.name}"
type = "A"
alias {
name = var.alb_name
zone_id = var.alb_zone_id
evaluate_target_health = true
}
}
resource "aws_route53_record" "company-admin-dns" {
zone_id = data.aws_route53_zone.selected.zone_id
name = "${var.company_name}-admin.${data.aws_route53_zone.selected.name}"
type = "A"
alias {
name = var.admin_alb_name
zone_id = var.admin_alb_zone_id
evaluate_target_health = true
}
}

0
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/output.tf

30
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dns/valiables.tf

@ -0,0 +1,30 @@
variable "domain_name" {
type = string
default = "kr-sensor.net"
}
variable "company_name" {
type = string
default = "new-company"
}
variable "alb_name" {
type = string
default = "kr-sensor.net"
}
variable "alb_zone_id" {
type = string
default = "kr-sensor.net"
}
variable "admin_alb_name" {
type = string
default = "kr-sensor.net"
}
variable "admin_alb_zone_id" {
type = string
default = "kr-sensor.net"
}

52
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/main.tf

@ -0,0 +1,52 @@
### DynamoDB
resource "aws_dynamodb_table" "alert_record_table" {
name = "alert_record_tokyo"
billing_mode = "PAY_PER_REQUEST" #
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
hash_key = "hashId"
range_key = "dateKey"
attribute { # attribute
name = "hashId"
type = "S"
}
attribute {
name = "dateKey"
type = "N"
}
tags = {
Name = "dynamodb-tk-tatemono"
Environment = "production"
}
}
resource "aws_dynamodb_table" "common_data_center" {
name = "common_data_center_tokyo"
billing_mode = "PAY_PER_REQUEST" #
stream_enabled = true
stream_view_type = "NEW_AND_OLD_IMAGES"
hash_key = "hashId"
range_key = "dateKey"
attribute { # attribute
name = "hashId"
type = "S"
}
attribute {
name = "dateKey"
type = "N"
}
tags = {
Name = "dynamodb-tk-tatemono"
Environment = "production"
}
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

6
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/output.tf

@ -0,0 +1,6 @@
output "alert_record_table_arn" {
value = aws_dynamodb_table.alert_record_table.stream_arn
}
output "common_data_center_arn" {
value = aws_dynamodb_table.common_data_center.stream_arn
}

25
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/dynamodb/variables.tf

@ -0,0 +1,25 @@
variable "aws_access_config_path" {
type = string
default = "/root/.aws/config"
}
variable "aws_access_credentials_path" {
type = string
default = "/root/.aws/credentials"
}
variable "project_name" {
type = string
default = "prod"
}
variable "region" {
type = string
default = "ap-northeast-1"
}
# variable "subnet_ids" {
# type = list
# }
# variable "sggroup_ids" {
# type = list
# }

141
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/main.tf

@ -0,0 +1,141 @@
#data apolicy
data aws_iam_policy AmazonEC2RoleforSSM{
name = "AmazonEC2RoleforSSM"
}
data aws_iam_policy AmazonS3FullAccess{
name = "AmazonS3FullAccess"
}
data aws_iam_policy CloudWatchAgentAdminPolicy{
name = "CloudWatchAgentAdminPolicy"
}
#Create a role
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role
resource "aws_iam_role" "ec2_role" {
name = "access-ec2-role2"
# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "ec2.amazonaws.com"
}
},
]
})
}
#Attach role to policy
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment
resource "aws_iam_policy_attachment" "ec2_policy_role" {
name = "ec2_attachment"
roles = [aws_iam_role.ec2_role.name]
policy_arn = data.aws_iam_policy.AmazonEC2RoleforSSM.arn
}
resource "aws_iam_policy_attachment" "ec2_policy_role2" {
name = "ec2_attachment"
roles = [aws_iam_role.ec2_role.name]
policy_arn = data.aws_iam_policy.AmazonS3FullAccess.arn
}
resource "aws_iam_policy_attachment" "ec2_policy_role3" {
name = "ec2_attachment"
roles = [aws_iam_role.ec2_role.name]
policy_arn = data.aws_iam_policy.CloudWatchAgentAdminPolicy.arn
}
#Attach role to an instance profile
#https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile
resource "aws_iam_instance_profile" "ec2_profile" {
name = "ec2-access-role"
role = aws_iam_role.ec2_role.name
}
# Create EC2 app 01
resource "aws_instance" "app-server-01" {
# count = 2
ami = var.instance_ami
instance_type = var.instance_type[1]
# subnet_id = aws_subnet.protected[count.index].id
subnet_id = var.sub_protected_id_01
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
# vpc_security_group_ids = [aws_security_group.sg_app.id]
vpc_security_group_ids = var.security_group_sg_app
key_name = var.key_name
root_block_device {
volume_size = "${var.instance_ebs_size}"
}
tags = {
Name: "${var.project_name}-data-process-hub}"
}
}
# Create EC2 app 02 modules\ec2\main.tf
resource "aws_instance" "app-server-02" {
# count = 2
ami = var.instance_ami
instance_type = var.instance_type[1]
# subnet_id = aws_subnet.protected[count.index].id
subnet_id = var.sub_protected_id_02
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
# vpc_security_group_ids = [aws_security_group.sg_app.id]
vpc_security_group_ids = var.security_group_sg_app
key_name = var.key_name
root_block_device {
volume_size = "${var.instance_ebs_size}"
}
tags = {
Name: "${var.project_name}-data-process-hub}"
}
}
# set public ip to bation
resource "aws_eip" "lb" {
instance = aws_instance.bation-server.id
domain = "vpc"
}
# Create EC2 Bation
resource "aws_instance" "bation-server" {
# count = 2
ami = var.instance_ami_bation
instance_type = var.instance_type[0]
# subnet_id = aws_subnet.public[0].id
subnet_id = var.sub_public_id
# vpc_security_group_ids = [aws_security_group.sg_bation.id]
vpc_security_group_ids = var.security_group_sg_bation
key_name = var.key_name
root_block_device {
volume_size = "8"
}
tags = {
Name: "${var.project_name}-bation"
}
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

7
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/output.tf

@ -0,0 +1,7 @@
output "aws_instance_app_server_01" {
value = aws_instance.app-server-01.id
}
output "aws_instance_app_server_02" {
value = aws_instance.app-server-02.id
}

68
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ec2/valiables.tf

@ -0,0 +1,68 @@
variable "sub_protected_id_01" {
type = string
}
variable "sub_protected_id_02" {
type = string
}
variable "security_group_sg_app" {
type = list(string)
}
variable "sub_public_id" {
type = string
}
variable "security_group_sg_bation" {
type = list(string)
}
variable "project_name" {
type = string
default = "prod"
}
variable "id" {
type = list(string)
default = ["01", "02", "03"]
}
variable "availability_zones" {
type = list(string)
default = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
}
variable "instance_ami" {
type = string
default = "ami-0329eac6c5240c99d"
}
variable "instance_ami_bation" {
type = string
default = "ami-0329eac6c5240c99d"
}
variable "iam_instance_profile_name" {
type = string
default = "tokyo-building-ec2-access-role"
}
variable "key_name"{
type = string
default = "tk-Zeta"
}
variable "instance_type"{
type = list(string)
default = [ "t2.micro", "t3.medium", "m5.large"]
}
variable "instance_ebs_size" {
type = string
default = "40"
}
# variable "sg_env_name"{
# type = list(string)
# default = [ "bation", "app", "nat_03" ]
# }
# mysql
#variable "app_name" {}

132
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/main.tf

@ -0,0 +1,132 @@
# # arn - ARN
# # registry_id - ID
# # repository_url - URL aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName
# # tags_all - default_tags配置块继承的标记
# resource "aws_iam_role" "ecr_get_role" {
# name = "ecr_get_role"
# assume_role_policy = jsonencode({
# Version = "2012-10-17",
# Statement = [
# {
# Action = "sts:AssumeRole",
# Effect = "Allow",
# Principal = {
# Service = "ecs-tasks.amazonaws.com",
# },
# },
# ],
# })
# }
# data "aws_iam_policy_document" "ecr_access_policy" {
# statement {
# effect = "Allow"
# actions = [
# "ecr:GetAuthorizationToken"
# ]
# resources = ["*"]
# }
# }
# resource "aws_iam_role_policy" "ecr_service_role_policy" {
# name = "${var.project_name}_ECR_ServiceRolePolicy"
# policy = data.aws_iam_policy_document.ecr_access_policy.json
# role = aws_iam_role.ecr_get_role.name
# }
data "aws_ecr_repository" "business" {
# name = "business"
name = var.repo_business_back
}
data "aws_ecr_repository" "business-web" {
# name = "business-web"
name = var.repo_business_web
}
data "aws_ecr_repository" "receiver" {
# name = "receiver"
name = var.repo_receiver
}
data "aws_ecr_repository" "sender" {
# name = "sender"
name = var.repo_sender
}
data "aws_ecr_repository" "mqtt" {
# name = "sender"
name = var.repo_mqtt
}
data "aws_ecr_repository" "adminback" {
# name = "sender"
name = var.repo_adminback
}
data "aws_ecr_repository" "adminweb" {
# name = "sender"
name = var.repo_adminweb
}
# data "aws_ecr_image" "business" {
# repository_name = "business"
# image_tag = "latest"
# }
# data "aws_ecr_image" "business-web" {
# repository_name = "business-web"
# image_tag = "latest"
# }
# data "aws_ecr_image" "receiver" {
# repository_name = "receiver"
# image_tag = "latest"
# }
# data "aws_ecr_image" "sender" {
# repository_name = "sender"
# image_tag = "latest"
# }
# resource "aws_ecr_repository" "business" {
# # name = "business"
# name = "${var.repo_business_name}_${var.project_name}"
# image_scanning_configuration {
# scan_on_push = true
# }
# image_tag_mutability = "MUTABLE"
# }
# resource "aws_ecr_repository" "business-web" {
# # name = "business-web"
# name = "${var.repo_business_name_web}_${var.project_name}"
# image_scanning_configuration {
# scan_on_push = true
# }
# image_tag_mutability = "MUTABLE"
# }
# resource "aws_ecr_repository" "receiver" {
# name = "${var.repo_business_receiver}_${var.project_name}"
# # name = "receiver"
# image_scanning_configuration {
# scan_on_push = true
# }
# image_tag_mutability = "MUTABLE"
# }
# resource "aws_ecr_repository" "sender" {
# # name = "sender"
# name = "${var.repo_business_sender}_${var.project_name}"
# image_scanning_configuration {
# scan_on_push = true
# }
# image_tag_mutability = "MUTABLE"
# }
# resource "aws_ecr_repository" "mqtt" {
# # name = "sender"
# name = "${var.repo_business_mqtt}_${var.project_name}"
# image_scanning_configuration {
# scan_on_push = true
# }
# image_tag_mutability = "MUTABLE"
# }
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

42
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/output.tf

@ -0,0 +1,42 @@
output "business_uri" {
value = "${data.aws_ecr_repository.business.repository_url}:latest"
}
output "business_name" {
value = data.aws_ecr_repository.business.name
}
output "business-web_uri" {
value = "${data.aws_ecr_repository.business-web.repository_url}:latest"
}
output "business-web_name" {
value = data.aws_ecr_repository.business-web.name
}
output "receiver_uri" {
value = "${data.aws_ecr_repository.receiver.repository_url}:latest"
}
output "receiver_name" {
value = data.aws_ecr_repository.receiver.name
}
output "sender_uri" {
value = "${data.aws_ecr_repository.sender.repository_url}:latest"
}
output "sender_name" {
value = data.aws_ecr_repository.sender.name
}
output "mqtt_uri" {
value = "${data.aws_ecr_repository.mqtt.repository_url}:latest"
}
output "mqtt_name" {
value = data.aws_ecr_repository.mqtt.name
}
output "adminback_uri" {
value = "${data.aws_ecr_repository.adminback.repository_url}:latest"
}
output "adminback_name" {
value = data.aws_ecr_repository.adminback.name
}
output "adminweb_uri" {
value = "${data.aws_ecr_repository.adminweb.repository_url}:latest"
}
output "adminweb_name" {
value = data.aws_ecr_repository.adminweb.name
}

21
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecr/valiables.tf

@ -0,0 +1,21 @@
variable "repo_business_back" {
type = string
}
variable "repo_business_web" {
type = string
}
variable "repo_receiver" {
type = string
}
variable "repo_sender" {
type = string
}
variable "repo_mqtt" {
type = string
}
variable "repo_adminback" {
type = string
}
variable "repo_adminweb" {
type = string
}

613
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/main.tf

@ -0,0 +1,613 @@
data aws_iam_role "ecs_task_role"{
name = "ecsTaskRole"
}
data aws_iam_role "ecs_task_execution_role"{
name = "ecsTaskExecutionRole"
}
resource "aws_cloudwatch_log_group" "ecs_task_logs" {
name = "/ecs/${var.company_name}-ecs-task"
}
resource "aws_ecs_cluster" "cluster" {
name = "${var.project_name}-${var.company_name}-cluster"
}
###### iotProcessEngine sender
resource "aws_ecs_task_definition" "sender" {
family = "${var.project_name}-${var.company_name}-sender"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = var.cpu_size[3]
memory = var.memory_size[3]
execution_role_arn = data.aws_iam_role.ecs_task_execution_role.arn
task_role_arn = data.aws_iam_role.ecs_task_role.arn
container_definitions = jsonencode([
{
name = "${var.sender_name}"
image = "${var.sender_image}"
logConfiguration = {
logDriver = "awslogs",
options = {
"awslogs-group" = "${aws_cloudwatch_log_group.ecs_task_logs.name}",
"awslogs-region" = "ap-northeast-1",
"awslogs-stream-prefix" = "${var.company_name}-sender-task"
}
}
essential = true
portMappings = [
{
containerPort = 8201
hostPort = 8201
Protocol = "http"
}
]
environment = [
{
"name" = "awsAccesskey"
"value" = "${var.awsAccesskey}"
},
{
"name" = "dynamicJdbcUrl"
"value" = "jdbc:mysql://${var.datasourceDNS}/%s"
},
{
"name" = "dataCenterSenderTargetUrl"
"value" = "${var.dataCenterSenderTargetUrl}"
},
{
"name" = "defaultRedisCacheTTL"
"value" = "${var.defaultRedisCacheTTL}"
},
{
"name" = "env"
"value" = "${var.env}"
},
{
"name" = "java_opts"
"value" = "${var.java_opts}"
},
{
"name" = "jdbcPassword"
"value" = "${var.jdbcPassword}"
},
{
"name" = "jdbcUrl"
"value" = "jdbc:mysql://${var.datasourceDNS}/data_center_admin"
},
{
"name" = "jdbcUsername"
"value" = "${var.jdbcUsername}"
},
{
"name" = "logLevel"
"value" = "${var.logLevel}"
},
{
"name" = "redisDatabase"
"value" = "${var.redisDatabase}"
},
{
"name" = "redisHost"
"value" = "${var.redisHost}"
},
{
"name" = "redisLockExpire"
"value" = "${var.redisLockExpire}"
},
{
"name" = "redisMaxActive"
"value" = "${var.redisMaxActive}"
},
{
"name" = "redisMaxIdle"
"value" = "${var.redisMaxIdle}"
},
{
"name" = "redisMaxWait"
"value" = "${var.redisMaxWait}"
},
{
"name" = "redisMinIdle"
"value" = "${var.redisredisMinIdleMaxWait}"
},
{
"name" = "redisPassword"
"value" = "${var.redisPassword}"
},
{
"name" = "redisPort"
"value" = "${var.redisPort}"
},
{
"name" = "redisShutdownTimeout"
"value" = "${var.redisShutdownTimeout}"
},
{
"name" = "redisTimeout"
"value" = "${var.redisTimeout}"
},
{
"name" = "secretkey"
"value" = "${var.awsSecretkey}"
},
{
"name" = "stompUrl"
"value" = "${var.mqBrokerId}.mq.ap-northeast-1.amazonaws.com"
},
{
"name" = "mqttTopic"
"value" = "${var.mqttTopic}"
},
{
"name" = "messageProtocol"
"value" = "kinesis"
},
{
"name" = "stompPassword"
"value" = "${var.stompPassword}"
},
{
"name" = "mqttUrl"
"value" = "ssl://${var.mqBrokerId}.mq.ap-northeast-1.amazonaws.com:8883"
},
{
"name" = "stompPort"
"value" = "61614"
},
{
"name" = "mqttEnableLog"
"value" ="TRUE"
},
{
"name" = "alarmRedisPassword"
"value" ="${var.alarmRedisPassword}"
},
{
"name" = "alarmRedisDatabase"
"value" ="${var.alarmRedisDatabase}"
},
{
"name" = "mqttPassword"
"value" ="${var.mqttPassword}"
},
{
"name" = "alarmRedisPort"
"value" ="6379"
},
{
"name" = "alarmRedisHost"
"value" ="${var.redisHost}"
},
{
"name" = "roid2Url"
"value" ="${var.roid2Url}"
},
{
"name" = "mqttNormalTopic"
"value" ="${var.mqttNormalTopic}"
},
{
"name" = "keepAliveInterval"
"value" ="60"
},
{
"name" = "mqttUsername"
"value" ="${var.mqttUsername}"
},
{
"name" = "stompUsername"
"value" ="${var.stompUsername}"
},
{
"name" = "mqttAlertTopic"
"value" ="${var.mqttAlertTopic}"
},
{
"name" = "mqttConnectionTimeout"
"value" = "60"
},
{
"name" = "roidAuthorization"
"value" = "${var.roidAuthorization}"
},
{
"name" = "queryPushInfoUrl"
"value" = "https://${var.queryPushInfoUrl}/api/targetConfig/config/v2/queryAlertForwardConfigByDeviceId"
},
{
"name" = "roidAlarmCancelUrl"
"value" = "${var.roidAlarmCancelUrl}"
},
{
"name" = "roidAlarmUrl"
"value" = "${var.roidAlarmUrl}"
},
{
"name" = "roid2Authorization"
"value" = "${var.roid2Authorization}"
},
{
"name" = "endpoint"
"value" ="${var.endpoint}"
},
{
"name" = "maxThreads"
"value" ="200"
},
{
"name" = "maxAcceptCount"
"value" ="100"
},
{
"name" = "maxConnections"
"value" ="10000"
},
]
}
])
}
resource "aws_ecs_service" "iotProcessEngine" {
# name = "iotProcessEngine"
name = "${var.company_name}-${var.sender_name}-serv"
cluster = aws_ecs_cluster.cluster.id
task_definition = aws_ecs_task_definition.sender.arn
launch_type = "FARGATE"
desired_count = 1
network_configuration {
subnets = tolist(var.autoscaling_subnet)
security_groups = tolist(var.sgapp_id)
}
load_balancer {
target_group_arn = var.sender_tg_8201_arn
container_name = "${var.sender_name}"
container_port = 8201
}
}
# receiver
resource "aws_ecs_task_definition" "receiver" {
family = "${var.project_name}-${var.company_name}-receiver"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = var.cpu_size[3]
memory = var.memory_size[3]
execution_role_arn = data.aws_iam_role.ecs_task_execution_role.arn
task_role_arn = data.aws_iam_role.ecs_task_role.arn
container_definitions = jsonencode([
{
name = "${var.receiver_name}"
# image = "923770123186.dkr.ecr.ap-northeast-1.amazonaws.com/business-web:latest"
image = "${var.receiver_image}"
logConfiguration = {
logDriver = "awslogs",
options = {
"awslogs-group" = "${aws_cloudwatch_log_group.ecs_task_logs.name}",
"awslogs-region" = "ap-northeast-1",
"awslogs-stream-prefix" = "${var.company_name}-receiver-task"
}
}
essential = true
portMappings = [
{
containerPort = 8200
hostPort = 8200
Protocol = "http"
}
]
environment = [
{
"name" = "env"
"value" = "${var.env}"
},
{
"name" = "dynamicJdbcUrl"
"value" = "jdbc:mysql://${var.datasourceDNS}/%s"
},
{
"name" = "jdbcPassword"
"value" = "${var.jdbcPassword}"
},
{
"name" = "jdbcUrl"
"value" = "jdbc:mysql://${var.datasourceDNS}/data_center_admin"
},
{
"name" = "jdbcUsername"
"value" = "${var.jdbcUsername}"
},
{
"name" = "redisHost"
"value" = "${var.redisHost}"
},
{
"name" = "redisPassword"
"value" = "${var.redisPassword}"
},
{
"name" = "redisPort"
"value" = "${var.redisPort}"
},
{
"name" = "redisDatabase"
"value" = "${var.redisDatabase}"
},
{
"name" = "redisTimeout"
"value" = "${var.redisTimeout}"
},
{
"name" = "redisMaxActive"
"value" = "${var.redisMaxActive}"
},
{
"name" = "redisLockExpire"
"value" = "${var.redisLockExpire}"
},
{
"name" = "redisMinIdle"
"value" = "${var.redisMinIdle}"
},
{
"name" = "redisMaxIdle"
"value" = "${var.redisMaxIdle}"
},
{
"name" = "redisShutdownTimeout"
"value" = "${var.redisShutdownTimeout}"
},
{
"name" = "redisMaxWait"
"value" = "${var.redisMaxWait}"
},
{
"name" = "dataCenterReceiverTargetUrl"
"value" = "http://${var.dataCenterReceiverTargetUrl}:8201"
},
{
"name" = "awsaccesskey"
"value" = "${var.awsAccesskey}"
},
{
"name" = "secretkey"
"value" = "${var.awsSecretkey}"
},
{
"name" = "deltaTopic"
"value" = "${var.deltaTopic}"
},
{
"name" = "deltaTopicHost"
"value" = "${var.deltaTopicHost}"
},
{
"name" = "deltaUserName"
"value" = "${var.deltaUserName}"
},
{
"name" = "deltaUsePassWordrName"
"value" = "${var.deltaUsePassWordrName}"
},
{
"name" = "deltaEnableSSL"
"value" = "${var.deltaEnableSSL}"
},
{
"name" = "dynamoTableName"
"value" = "${var.dynamoTableName}"
},
{
"name" = "logLevel"
"value" = "${var.logLevel}"
},
{
"name" = "JAVA_OPTS"
"value" = "${var.JAVA_OPTS}"
},
{
"name" = "mqttUrl"
"value" = "ssl://${var.mqBrokerId}.mq.ap-northeast-1.amazonaws.com:8883"
},
{
"name" = "mqttUsername"
"value" = "${var.mqttUsername}"
},
{
"name" = "mqttPassword"
"value" = "${var.mqttPassword}"
},
{
"name" = "mqttTopic"
"value" = "${var.mqttTopic}"
},
{
"name" = "mqttEnableLog"
"value" = "${var.mqttEnableLog}"
},
{
"name" = "keepAliveInterval"
"value" = "${var.keepAliveInterval}"
},
{
"name" = "mqttConnectionTimeout"
"value" = "${var.mqttConnectionTimeout}"
},
{
"name" = "mqttAlertTopic"
"value" = "${var.mqttAlertTopic}"
},
{
"name" = "mqttNormalTopic"
"value" = "${var.mqttNormalTopic}"
},
]
}
])
}
resource "aws_ecs_service" "iotDatareceiver" {
# name = "iotDatareceiver"
name = "${var.company_name}-${var.receiver_name}-serv"
cluster = aws_ecs_cluster.cluster.id
task_definition = aws_ecs_task_definition.receiver.arn
launch_type = "FARGATE"
desired_count = 1
network_configuration {
subnets = tolist(var.autoscaling_subnet)
security_groups = tolist(var.sgapp_id)
}
load_balancer {
target_group_arn = var.receiver_tg_8200_arn
container_name = "${var.receiver_name}"
container_port = 8200
}
}
# sender
resource "aws_appautoscaling_target" "ecs_target_sender" {
max_capacity = 12
min_capacity = 2
resource_id = "service/${aws_ecs_cluster.cluster.name}/${aws_ecs_service.iotProcessEngine.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}
#sender add
resource "aws_appautoscaling_policy" "sender_scale_up" {
name = "${var.company_name}-sender-scale-up"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.ecs_target_sender.resource_id
scalable_dimension = aws_appautoscaling_target.ecs_target_sender.scalable_dimension
service_namespace = aws_appautoscaling_target.ecs_target_sender.service_namespace
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_upper_bound = 0
scaling_adjustment = 1
}
}
}
resource "aws_appautoscaling_policy" "sender_scale_down" {
name = "${var.company_name}-sender-scale-down"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.ecs_target_sender.resource_id
scalable_dimension = aws_appautoscaling_target.ecs_target_sender.scalable_dimension
service_namespace = aws_appautoscaling_target.ecs_target_sender.service_namespace
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_upper_bound = 0
scaling_adjustment = -1
}
}
}
#receiver add
resource "aws_appautoscaling_target" "ecs_target_receiver" {
max_capacity = 12
min_capacity = 2
resource_id = "service/${aws_ecs_cluster.cluster.name}/${aws_ecs_service.iotDatareceiver.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}
resource "aws_appautoscaling_policy" "receiver_scale_up" {
name = "${var.company_name}-receiver-scale-up"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.ecs_target_receiver.resource_id
scalable_dimension = aws_appautoscaling_target.ecs_target_receiver.scalable_dimension
service_namespace = aws_appautoscaling_target.ecs_target_receiver.service_namespace
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_upper_bound = 0
scaling_adjustment = 1
}
}
}
resource "aws_appautoscaling_policy" "receiver_scale_down" {
name = "${var.company_name}-receiver-scale-down"
policy_type = "StepScaling"
resource_id = aws_appautoscaling_target.ecs_target_receiver.resource_id
scalable_dimension = aws_appautoscaling_target.ecs_target_receiver.scalable_dimension
service_namespace = aws_appautoscaling_target.ecs_target_receiver.service_namespace
step_scaling_policy_configuration {
adjustment_type = "ChangeInCapacity"
cooldown = 60
metric_aggregation_type = "Maximum"
step_adjustment {
metric_interval_upper_bound = 0
scaling_adjustment = -1
}
}
}
#
resource "aws_cloudwatch_metric_alarm" "high_request_count_per_target" {
alarm_name = "${var.project_name}-${var.company_name}-high-request"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = 5
metric_name = "RequestCountPerTarget"
namespace = "AWS/ApplicationELB"
period = 60
statistic = "Average"
threshold = 20000
alarm_description = "Alarm when request count per target exceeds 20000 per minute"
dimensions = {
TargetGroup = var.sender_tg_8201_arn_suffix # Replace with your Target Group ARN suffix
}
actions_enabled = true
alarm_actions = [aws_appautoscaling_policy.sender_scale_up.arn, aws_appautoscaling_policy.receiver_scale_up.arn]
}
resource "aws_cloudwatch_metric_alarm" "low_request_count_per_target" {
alarm_name = "${var.project_name}-${var.company_name}-low-request"
comparison_operator = "LessThanThreshold"
evaluation_periods = 5
metric_name = "RequestCountPerTarget"
namespace = "AWS/ApplicationELB"
period = 60
statistic = "Average"
threshold = 15000
alarm_description = "Alarm when request count per target lower 15000 per minute"
dimensions = {
TargetGroup = var.sender_tg_8201_arn_suffix # Replace with your Target Group ARN suffix
}
actions_enabled = true
alarm_actions = [aws_appautoscaling_policy.sender_scale_down.arn, aws_appautoscaling_policy.receiver_scale_down.arn]
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

13
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/user_data.sh

@ -0,0 +1,13 @@
#!/bin/bash
echo ECS_CLUSTER='${ecs_cluster_name}' >> /etc/ecs/ecs.config
# sudo reboot
# systemctl restart ecs
# sudo yum install -y wget aws-cli
sudo yum update -y ecs-init
sudo systemctl restart docker
# sleep 15
# tg_arn='arn:aws:elasticloadbalancing:ap-northeast-1:923770123186:targetgroup/iot-process-engine-tg/8d2cd9d3ef4de6e3'
# ec2_id=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
# aws --region ap-northeast-1 elbv2 deregister-targets --target-group-arn $tg_arn --targets Id=$ec2_id,Port=8201

366
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/ecs_fargate/valiables.tf

@ -0,0 +1,366 @@
variable "project_name" {
type = string
}
variable "company_name" {
type = string
}
# variable "iotmqtt_tg_1883_arn" {
# type = string
# }
# variable "iotmqtt_tg_8083_arn" {
# type = string
# }
# variable "iotmqtt_tg_8883_arn" {
# type = string
# }
# variable "businessBack_tg_20016_arn" {
# type = string
# }
# variable "businessWeb_tg_80_arn" {
# type = string
# }
variable "sender_tg_8201_arn" {
type = string
}
variable "sender_tg_8201_arn_suffix" {
type = string
}
# variable "iotmqtt_tg_8089_arn" {
# type = string
# }
# variable "iotmqtt_tg_18083_arn" {
# type = string
# }
# variable "adminBack_tg_20015_arn" {
# type = string
# }
variable "receiver_tg_8200_arn" {
type = string
}
# variable "adminWeb_tg_80_arn" {
# type = string
# }
variable "cpu_size" {
type = list(number)
default = [256, 512, 1024, 2048, 4096]
}
variable "memory_size" {
type = list(number)
default = [512, 1024, 2048, 4096, 8192]
}
# variable "container_name" {}
variable "autoscaling_subnet" {}
variable "sgapp_id" {}
variable "sender_name" {
type = string
}
variable "sender_image" {
type = string
}
variable "receiver_name" {
type = string
}
variable "receiver_image" {
type = string
}
variable "business_name" {
type = string
}
variable "business_image" {
type = string
}
variable "business_web_name" {
type = string
}
variable "business_web_image" {
type = string
}
variable "adminWeb_name" {
type = string
}
variable "adminWeb_image" {
type = string
}
variable "adminback_name" {
type = string
}
variable "adminback_image" {
type = string
}
variable "mqtt_name" {
type = string
}
variable "mqtt_image" {
type = string
}
# variable "redisDatabase" {
# type = string
# default = "14"
# }
variable "awsAccesskey" {
type = string
default = "AKIA4MTWHEP3W7M4BGP5"
}
# variable "awsBucket" {
# type = string
# default = "databucket-381659385655"
# }
variable "mqttUrl" {
type = string
default = "tcp://106.75.71.119:1883"
}
variable "mqttUsername" {
type = string
default = "techsor"
}
variable "mqttPassword" {
type = string
default = "Abc#123456xyz"
}
variable "mqttTopic" {
type = string
default = "topic"
}
variable "mqttEnableLog" {
type = string
default = "true"
}
variable "keepAliveInterval" {
type = string
default = "60"
}
variable "mqttConnectionTimeout" {
type = string
default = "60"
}
variable "mqttAlertTopic" {
type = string
default = "alertTopic"
}
variable "mqttNormalTopic" {
type = string
}
variable "apiEnable" {
type = string
default = "false"
}
variable "webLoginUrl" {
type = string
default = "http://www-stg.kr-sensor.net/#/user/login"
}
variable "thirdBusinessHost" {
type = string
default = "http://www-stg.kr-sensor.net/api"
}
variable "awsSecretkey" {
type = string
default = "FY1nQm6nQg1GxDcyIzk0rQRMiYwSoc4GkLZrVwNr"
}
variable "datacenterV1QueryUrl" {
type = string
default = "https://api-stg.ttkdatatechbuild.com/datacenter/v1/query"
}
variable "mybatisLogLevel" {
type = string
default = "ERROR"
}
variable "datasourceDNS" {
type = string
default = ""
}
variable "datasourcePassword" {
type = string
default = "Abc#123456xyz"
}
variable "datasourceTimeZone" {
type = string
default = "Asia/Tokyo"
}
variable "datasourceUsername" {
type = string
default = "techsor"
}
variable "ibatisLoggingLog" {
type = string
default = "ERROR"
}
variable "ibatisLoggingLogFactory" {
type = string
default = "ERROR"
}
variable "loggingAppender" {
type = string
default = "CONSOLELOG"
}
variable "loggingLevel" {
type = string
default = "DEBUG"
}
variable "loggingPath" {
type = string
default = "/home/data-center-business/log"
}
variable "redisHost" {
type = string
default = "replication-group-tokyo-build.ncvpel.ng.0001.apne1.cache.amazonaws.com"
}
variable "redisPassword" {
type = string
default = ""
}
variable "dataCenterSenderTargetUrl" {
type = string
default = "http://43.163.243.201:8030/nesic/deviceId/"
}
variable "defaultRedisCacheTTL" {
type = string
default = "3600000"
}
variable "env" {
type = string
default = "prd"
}
variable "java_opts" {
type = string
default = "-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:G1NewSizePercent=20 -XX:G1MaxNewSizePercent=60 -XX:InitialHeapSize=2g -Xmx2500m -XX:MetaspaceSize=128m -XX:+PrintGCDetails -XX:+PrintGCDatestamps -Xloggc:/app/gc.log"
}
variable "jdbcPassword" {
type = string
default = "Abc#123456xyz"
}
variable "jdbcUsername" {
type = string
default = "techsor"
}
variable "logLevel" {
type = string
default = "ERROR"
}
variable "redisDatabase" {
type = string
default = "14"
}
variable "redisLockExpire" {
type = string
default = "500"
}
variable "redisMaxActive" {
type = string
default = "7000"
}
variable "redisMaxIdle" {
type = string
default = "7000"
}
variable "redisMaxWait" {
type = string
default = "10000"
}
variable "redisredisMinIdleMaxWait" {
type = string
default = "0"
}
variable "redisPort" {
type = string
default = "6379"
}
variable "redisShutdownTimeout" {
type = string
default = "30000"
}
variable "redisTimeout" {
type = string
default = "30000"
}
# variable "dynamicJdbcUrl" {
# type = string
# default = "jdbc:mysql://rm-bp11k2zm2fr7864428o.mysql.rds.aliyuncs.com/"
# }
variable "redisMinIdle" {
type = string
default = "0"
}
variable "dataCenterReceiverTargetUrl" {
type = string
default = "http://39.107.211.201:820"
}
variable "deltaTopic" {
type = string
default = "Publish_Topic"
}
variable "deltaTopicHost" {
type = string
default = "tcp://:1883"
}
variable "deltaUserName" {
type = string
default = "techsor23"
}
variable "deltaUsePassWordrName" {
type = string
default = "techsorAsd123456"
}
variable "deltaEnableSSL" {
type = string
default = "false"
}
variable "dynamoTableName" {
type = string
default = "tokyo-building"
}
variable "JAVA_OPTS" {
type = string
default = "-XX:+UseZGC -Xms1g -Xmx2g -XX:MetaspaceSize=256m -Xlog:gc*:file=/app/gc.log:time,level,tags"
}
variable "mqBrokerId" {
type = string
default = "b-f5eeb911-97dd-4457-8321-185bc4aa5666-1"
}
# variable "stompUrl" {
# type = string
# default = "b-xxxx-xxxx-xxxx-xxxx-xxxx-1.mq.ap-northeast-1.amazonaws.com"
# }
variable "endpoint" {
type = string
default = "test"
}
variable "stompPassword" {
type = string
default = "Abc#123456xyz"
}
variable "alarmRedisPassword" {
type = string
default = ""
}
variable "alarmRedisDatabase" {
type = string
}
variable "roid2Url" {
type = string
}
variable "roidAlarmUrl" {
type = string
}
variable "roidAlarmCancelUrl" {
type = string
}
variable "stompUsername" {
type = string
default = "techsor"
}
variable "queryPushInfoUrl" {
type = string
}
variable "roidAuthorization" {
type = string
}
variable "roid2Authorization" {
type = string
}

118
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/main.tf

@ -0,0 +1,118 @@
data "aws_caller_identity" "current" {}
resource "aws_iam_role" "pipes-role" {
name = "${var.company_name}_pipes_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = {
Effect = "Allow"
Action = "sts:AssumeRole"
Principal = {
Service = "pipes.amazonaws.com"
}
Condition = {
StringEquals = {
"aws:SourceAccount" = "${data.aws_caller_identity.current.id}"
}
}
}
})
}
resource "aws_iam_role_policy" "source-policy" {
role = aws_iam_role.pipes-role.id
name = "${var.company_name}_source-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"kinesis:DescribeStream",
"kinesis:DescribeStreamSummary",
"kinesis:GetRecords",
"kinesis:GetShardIterator",
"kinesis:ListStreams",
"kinesis:ListShards"
],
Resource = [
"${var.aws_kinesis_stream_arn}",
]
},
]
})
}
resource "aws_iam_role_policy" "target-policy" {
role = aws_iam_role.pipes-role.id
name = "${var.company_name}_target-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"lambda:InvokeFunction"
],
Resource = [
"${var.aws_lambda_arn}",
]
},
]
})
}
# resource "aws_sqs_queue" "source" {}
# resource "aws_iam_role_policy" "target" {
# role = aws_iam_role.example.id
# policy = jsonencode({
# Version = "2012-10-17"
# Statement = [
# {
# Effect = "Allow"
# Action = [
# "sqs:SendMessage",
# ],
# Resource = [
# aws_sqs_queue.target.arn,
# ]
# },
# ]
# })
# }
resource "aws_pipes_pipe" "example" {
depends_on = [aws_iam_role_policy.source-policy, aws_iam_role_policy.target-policy]
name = "${var.company_name}-kinesis-lambda-pipes"
role_arn = aws_iam_role.pipes-role.arn
source = var.aws_kinesis_stream_arn
target = var.aws_lambda_arn
source_parameters {
kinesis_stream_parameters {
starting_position = "LATEST"
batch_size = 100
maximum_record_age_in_seconds = 3600
maximum_retry_attempts = 3
parallelization_factor = 10
}
}
target_parameters {
lambda_function_parameters {
invocation_type = "FIRE_AND_FORGET"
}
}
}
# data "aws_caller_identity" "current" {}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

0
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/output.tf

13
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/eventbridge/valiables.tf

@ -0,0 +1,13 @@
variable "company_name" {
type = string
}
variable "aws_kinesis_stream_arn" {
type = string
}
variable "aws_lambda_arn" {
type = string
}

42
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/main.tf

@ -0,0 +1,42 @@
data aws_iam_role "gluejob_role"{
name = "AWSGlueServiceRole"
}
resource "aws_glue_job" "example" {
name = "${var.project_name}-${var.company_name}-job"
role_arn = data.aws_iam_role.gluejob_role.arn
command {
# name = "pythonshell"
script_location = "s3://aws-glue-assets-381659385655-ap-northeast-1/scripts/tokyobuild-gluejob.py"
python_version = "3"
}
default_arguments = {
"--jdbcUrl" = "jdbc:mysql://${var.aurora_endpoint}:3306/third"
}
connections = ["Mysql"]
worker_type = "G.1X"
number_of_workers = 4
}
resource "aws_glue_trigger" "example_trigger" {
name = "${var.project_name}-${var.company_name}-trigger"
type = "SCHEDULED"
schedule = "cron(0 15 * * ? *)"
actions {
job_name = aws_glue_job.example.name
}
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

0
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/output.tf

12
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/glue_job/valiables.tf

@ -0,0 +1,12 @@
variable "project_name" {
type = string
}
variable "company_name" {
type = string
}
variable "aurora_endpoint" {
type = string
# default = "sensor-plantform.cluster-cde6q2assvmn.ap-northeast-1.rds.amazonaws.com"
}

89
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/main.tf

@ -0,0 +1,89 @@
# kinesis data stream
resource "aws_kinesis_stream" "kinesis" {
name = "${var.company_name}-stream"
stream_mode_details {
stream_mode = "ON_DEMAND"
}
}
# data "aws_caller_identity" "current" {}
# # datalake
# resource "aws_s3_bucket" "bucket" {
# bucket = "${var.project_name}-datalake-${data.aws_caller_identity.current.account_id}"
# }
# resource "aws_kinesis_firehose_delivery_stream" "extended_s3_stream" {
# name = "${var.project_name}-to-s3-stream"
# destination = "extended_s3"
# extended_s3_configuration {
# role_arn = aws_iam_role.firehose_role.arn
# bucket_arn = aws_s3_bucket.bucket.arn
# # buffering_size = 128
# dynamic_partitioning_configuration {
# enabled = true
# }
# prefix = "firehosepart/date=!{partitionKeyFromQuery:dateKey}/"
# error_output_prefix = "errorpart/"
# processing_configuration {
# enabled = "true"
# processors {
# type = "MetadataExtraction"
# # parameters {
# # parameter_name = "JsonParsingEngine"
# # parameter_value = "JQ-1.6"
# # }
# parameters {
# parameter_name = "MetadataExtractionQuery"
# parameter_value = "{dateKey:.dateKey}"
# }
# }
# }
# }
# }
# data "aws_iam_policy_document" "firehose_assume_role" {
# statement {
# effect = "Allow"
# principals {
# type = "Service"
# identifiers = ["firehose.amazonaws.com"]
# }
# actions = ["sts:AssumeRole"]
# }
# }
# resource "aws_iam_role" "firehose_role" {
# name = "firehose_test_role"
# assume_role_policy = data.aws_iam_policy_document.firehose_assume_role.json
# }
# data "aws_iam_policy_document" "lambda_assume_role" {
# statement {
# effect = "Allow"
# principals {
# type = "Service"
# identifiers = ["lambda.amazonaws.com"]
# }
# actions = ["sts:AssumeRole"]
# }
# }
# resource "aws_iam_role" "lambda_iam" {
# name = "lambda_iam"
# assume_role_policy = data.aws_iam_policy_document.lambda_assume_role.json
# }
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

7
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/output.tf

@ -0,0 +1,7 @@
output "aws_kinesis_stream_name" {
value = aws_kinesis_stream.kinesis.name
}
output "aws_kinesis_stream_arn" {
value = aws_kinesis_stream.kinesis.arn
}

6
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/kinesis/valiables.tf

@ -0,0 +1,6 @@
variable "company_name" {
type = string
}

BIN
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/kinesisStreamToLambdaDemo-b9494dc1-fa94-4184-ab34-2707c917b543.zip

Binary file not shown.

140
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/main.tf

@ -0,0 +1,140 @@
# aws role
resource "aws_iam_role" "lambda_role" {
name = "kinesisToLambda_${var.company_name}_role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Effect = "Allow",
Principal = {
Service = "lambda.amazonaws.com",
},
},
],
})
}
data "aws_iam_policy" "AWSLambdaBasicExecutionRole" {
name = "AWSLambdaBasicExecutionRole"
}
data "aws_iam_policy" "AWSLambdaKinesisExecutionRole" {
name = "AWSLambdaKinesisExecutionRole"
}
data "aws_iam_policy" "AWSLambdaVPCAccessExecutionRole" {
name = "AWSLambdaVPCAccessExecutionRole"
}
resource "aws_iam_role_policy_attachment" "lambda_execution_policy_attachment" {
policy_arn = data.aws_iam_policy.AWSLambdaBasicExecutionRole.arn
role = aws_iam_role.lambda_role.name
}
resource "aws_iam_role_policy_attachment" "lambda_execution_policy_attachment2" {
policy_arn = data.aws_iam_policy.AWSLambdaKinesisExecutionRole.arn
role = aws_iam_role.lambda_role.name
}
resource "aws_iam_role_policy_attachment" "lambda_execution_policy_attachment3" {
policy_arn = data.aws_iam_policy.AWSLambdaVPCAccessExecutionRole.arn
role = aws_iam_role.lambda_role.name
}
resource "aws_lambda_function" "kinesisStreamToLambda" {
function_name = "kinesisToLambda_${var.company_name}"
runtime = "java11"
handler = "com.techsensor.aws.mqtt.lambda.handler.AwsMqttHandler::handleRequest"
filename = "./modules/lambda/kinesisStreamToLambdaDemo-b9494dc1-fa94-4184-ab34-2707c917b543.zip"
role = aws_iam_role.lambda_role.arn # 使 Lambda
memory_size = 512
timeout = 900
snap_start {
apply_on = "PublishedVersions"
}
vpc_config {
subnet_ids = var.subnet_ids # ID
security_group_ids = var.sggroup_ids # ID
}
environment {
variables = {
AURORA_PASSWORD = "${var.AURORA_PASSWORD}",
AURORA_URL = "jdbc:mysql://${var.AURORA_URL}:3306/third",
AURORA_USERNAME = "${var.AURORA_USERNAME}",
AWS_ACCESS = "${var.AWS_ACCESS}",
AWS_SECRET = "${var.AWS_SECRET}",
FIREHOSE_DELIVERY_STREAM_NAME="${var.aws_kinesis_stream_name}",
PUSH_URL_METCOM = "http://47.74.30.186:8080/rawJson/post/metcom",
QUERY_PUSH_INFO = "https://iothub-web-stg.ttkdatatechbuild.com/api/targetConfig/config/v2/queryByDeviceId?deviceId="
SINGLE_ID_TABLE_NAME = "rawData_single_id"
TABLE_NAME = "rawData",
}
}
}
# resource "aws_lambda_event_source_mapping" "alert_record_dynamodb_trigger" {
# event_source_arn = var.alert_record_stream_arn_tk
# function_name = aws_lambda_function.sensorAlermTransfer_tk.arn
# starting_position = "LATEST"
# }
######################
# resource "aws_lambda_function" "ddb_to_filehorse_iot_tk" {
# function_name = "ddb_to_filehorse_iot_tk"
# runtime = "python3.11"
# handler = "index.handler"
# filename = "./modules/lambda/ddb-to-filehorse-iot.zip"
# role = aws_iam_role.lambda_role.arn # 使 Lambda
# environment {
# variables = {
# DeliveryStreamName = "ddb-to-s3-stream"
# }
# }
# }
# resource "aws_lambda_event_source_mapping" "ddb_to_filehorse_iot_dynamodb_trigger" {
# event_source_arn = var.common_data_stream_arn_tk
# function_name = aws_lambda_function.ddb_to_filehorse_iot_tk.arn
# starting_position = "LATEST"
# }
# #######################
# resource "aws_lambda_function" "dynamodbStreamsToDbm_tk" {
# function_name = "dynamodbStreamsToDbm_tk"
# runtime = "java11"
# handler = "index.handler"
# filename = "./modules/lambda/dynamodbStreamsToDbm.zip"
# role = aws_iam_role.lambda_role.arn # 使 Lambda
# vpc_config {
# subnet_ids = var.subnet_ids # ID
# security_group_ids = var.sggroup_ids # ID
# }
# environment {
# variables = {
# PUSH_URL_METCOM = "http://47.74.30.186:8080/rawJson/post/metcom"
# QUERY_PUSH_INFO = "http://web-alb-481573367.ap-northeast-1.elb.amazonaws.com:20008/api/targetConfig/config/v2/queryByDeviceId?deviceId="
# }
# }
# }
# resource "aws_lambda_event_source_mapping" "dynamodbStreamsToDbm_dynamodb_trigger" {
# event_source_arn = var.common_data_stream_arn_tk
# function_name = aws_lambda_function.dynamodbStreamsToDbm_tk.arn
# starting_position = "LATEST"
# }
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

3
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/output.tf

@ -0,0 +1,3 @@
output "aws_lambda_arn" {
value = aws_lambda_function.kinesisStreamToLambda.arn
}

31
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/lambda/variables.tf

@ -0,0 +1,31 @@
variable "company_name" {
type = string
}
variable "subnet_ids" {
type = list
}
variable "sggroup_ids" {
type = list
}
variable "AURORA_PASSWORD" {
type = string
default = "Abc#123456xyz"
}
variable "AURORA_USERNAME" {
type = string
default = "techsor"
}
variable "AURORA_URL" {
type = string
}
variable "AWS_ACCESS" {
type = string
}
variable "AWS_SECRET" {
type = string
}
variable "aws_kinesis_stream_name" {
type = string
}

217
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/main.tf

@ -0,0 +1,217 @@
resource "aws_mq_configuration" "sensor" {
description = "Example Configuration"
name = "${var.project_name}-config"
engine_type = "ActiveMQ"
engine_version = "5.17.6"
data = <<DATA
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<broker xmlns="http://activemq.apache.org/schema/core" schedulePeriodForDestinationPurge="10000">
<!--
A configuration contains all of the settings for your ActiveMQ broker, in XML format (similar to ActiveMQ's activemq.xml file).
You can create a configuration before creating any brokers. You can then apply the configuration to one or more brokers.
You can use additional attributes for the broker element above. These attributes allow you to configure broker-wide settings.
For more information, see Configuration and Amazon MQ Broker Configuration Parameters in the Amazon MQ Developer Guide:
https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/amazon-mq-broker-configuration-parameters.html
-->
<!--
Mirrored queues let you send a copy of each message to a topic with a similar name automatically.
For more information, see http://activemq.apache.org/mirrored-queues.html
Virtual destinations let you configure advanced routing of messages between destinations.
For more information, see http://activemq.apache.org/virtual-destinations.html
-->
<!--
<destinationInterceptors>
<mirroredQueue copyMessage="true" postfix=".qmirror" prefix=""/>
<virtualDestinationInterceptor>
<virtualDestinations>
<virtualTopic name="&gt;" prefix="VirtualTopicConsumers.*." selectorAware="false"/>
<compositeQueue name="MY.QUEUE">
<forwardTo>
<queue physicalName="FOO"/>
<topic physicalName="BAR"/>
</forwardTo>
</compositeQueue>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
-->
<!--
By default, Amazon MQ optimizes for queues with fast consumers:
Consumers are considered fast if they are able to keep up with the rate of messages generated by producers.
Consumers are considered slow if a queue builds up a backlog of unacknowledged messages, potentially causing a decrease in producer throughput.
To instruct Amazon MQ to optimize for queues with slow consumers, set the concurrentStoreAndDispatchQueues attribute to false.
For more information, see https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/ensuring-effective-amazon-mq-performance.html
-->
<!--
<persistenceAdapter>
<kahaDB concurrentStoreAndDispatchQueues="false"/>
</persistenceAdapter>
-->
<destinationPolicy>
<policyMap>
<policyEntries>
<!--
gcInactiveDestinations is used to automatically purge inactive destinations
preventing them from unnecessarily using broker resources.
An 'inactive' destination is one that has no messages pending and no consumers connected.
For more information, see: http://activemq.apache.org/delete-inactive-destinations.html
-->
<policyEntry topic="&gt;" gcInactiveDestinations="true" inactiveTimoutBeforeGC="600000">
<!--
The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see: http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
<policyEntry queue="&gt;" gcInactiveDestinations="true" inactiveTimoutBeforeGC="600000" />
<!--
Destination policies let you configure a rich set of behaviors for your queues and topics.
For more information, see http://activemq.apache.org/per-destination-policies.html
-->
<!--
<policyEntry topic="FOO.&gt;">
<dispatchPolicy>
<roundRobinDispatchPolicy/>
</dispatchPolicy>
<subscriptionRecoveryPolicy>
<lastImageSubscriptionRecoveryPolicy/>
</subscriptionRecoveryPolicy>
</policyEntry>
<policyEntry advisoryForConsumed="true" tempTopic="true"/>
<policyEntry advisoryForConsumed="true" tempQueue="true"/>
-->
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
Typically, destinations are created automatically when they are used. Amazon MQ lets you create destinations when the broker is started.
For more information, see http://activemq.apache.org/configure-startup-destinations.html
-->
<!--
<destinations>
<queue physicalName="FOO.BAR"/>
<topic physicalName="SOME.TOPIC"/>
</destinations>
-->
<!--
You can control advanced ActiveMQ features using plugins.
-->
<plugins>
<!--
The Authorization plugin allows you to control the groups of users that are allowed to perform certain operations on your destinations.
For more information, see http://activemq.apache.org/security.html
-->
<!--
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry admin="guests,users" queue="GUEST.&gt;" read="guests" write="guests,users"/>
<authorizationEntry admin="guests,users" read="guests,users" topic="ActiveMQ.Advisory.&gt;" write="guests,users"/>
</authorizationEntries>
<tempDestinationAuthorizationEntry>
<tempDestinationAuthorizationEntry admin="tempDestinationAdmins" read="tempDestinationAdmins" write="tempDestinationAdmins"/>
</tempDestinationAuthorizationEntry>
</authorizationMap>
</map>
</authorizationPlugin>
-->
<!--
The Discarding DLQ plugin simplifies the configuration of your global dead-letter queue strategy.
You can take advantage of a more granular per-destination control by using destination policies.
For more information, see http://activemq.apache.org/message-redelivery-and-dlq-handling.html
-->
<!--
<discardingDLQBrokerPlugin dropAll="true" dropTemporaryQueues="true" dropTemporaryTopics="true"/>
-->
<!--
The Force Persistency Mode plugin can override the persistency mode set on messages.
-->
<!--
<forcePersistencyModeBrokerPlugin persistenceFlag="true"/>
-->
<!--
The Redelivery plugin extends the capabilities of destination policies with respect to message redelivery.
For more information, see http://activemq.apache.org/message-redelivery-and-dlq-handling.html
-->
<!--
<redeliveryPlugin fallbackToDeadLetter="true" sendToDlqIfMaxRetriesExceeded="true">
<redeliveryPolicyMap>
<redeliveryPolicyMap>
<redeliveryPolicyEntries>
<redeliveryPolicy maximumRedeliveries="4" queue="SpecialQueue" redeliveryDelay="10000"/>
</redeliveryPolicyEntries>
<defaultEntry>
<redeliveryPolicy initialRedeliveryDelay="5000" maximumRedeliveries="4" redeliveryDelay="10000"/>
</defaultEntry>
</redeliveryPolicyMap>
</redeliveryPolicyMap>
</redeliveryPlugin>
-->
<!--
The Statistics plugin lets you query broker or destination statistics by sending messages to the broker.
For more information, see http://activemq.apache.org/statisticsplugin.html
-->
<!--
<statisticsBrokerPlugin/>
-->
<!--
The Timestamping plugin lets the broker use server-side time instead of client-provided time for messages.
For more information, see http://activemq.apache.org/timestampplugin.html
-->
<!--
<timeStampingBrokerPlugin ttlCeiling="86400000" zeroExpirationOverride="86400000"/>
-->
</plugins>
<!--
Network connectors let you connect brokers into networks of brokers.
For more information, see Creating and Configuring an Amazon MQ Network of Brokers
(https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/amazon-mq-creating-configuring-network-of-brokers.html)
in the Amazon MQ Developer Guide and also Networks of Brokers
(http://activemq.apache.org/networks-of-brokers.html) in the ActiveMQ documentation.
-->
<!--
<networkConnectors>
<networkConnector name="myNetworkConnector" userName="commonUser" uri="masterslave:(ssl://b-1a2b3c4d-1.mq.region.amazonaws.com:61617,ssl://b-1a2b3c4d-2.mq.region.amazonaws.com:61617)"/>
</networkConnectors>
-->
</broker>
DATA
}
resource "aws_mq_broker" "ActiveMQ" {
broker_name = "${var.project_name}-mq"
# configuration {
# id = aws_mq_configuration.sensor.id
# revision = aws_mq_configuration.sensor.latest_revision
# }
subnet_ids = var.subnet_mq_ids
publicly_accessible = false
engine_type = "ActiveMQ"
engine_version = "5.17.6"
host_instance_type = "mq.t3.micro"
security_groups = [ "${var.sg_mq}"]
user {
username = var.username
password = var.password
}
logs {
general = true
}
}

3
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/output.tf

@ -0,0 +1,3 @@
output "ActiveMQBrokerId" {
value = aws_mq_broker.ActiveMQ.id
}

18
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/mq/valiables.tf

@ -0,0 +1,18 @@
variable "project_name" {
type = string
default = "prod"
}
variable "username" {
type = string
default = "techsor"
}
variable "password" {
type = string
default = "Abc#123456xyz"
}
variable "subnet_mq_ids" {
type = list(string)
}
variable "sg_mq" {
type = string
}

68
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/main.tf

@ -0,0 +1,68 @@
# data exist vpc
data "aws_vpc" "vpc_sensor_plantform" {
filter {
name = "tag:Name"
values = ["${var.vpc_name}"]
}
}
# data "aws_subnets" "public"
data "aws_subnets" "public_subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc_sensor_plantform.id]
}
tags = {
Tier = "public"
}
}
# # data "aws_subnet" "public"
# data "aws_subnet" "public_subnet"{
# for_each = toset(data.aws_subnets.public_subnets.ids)
# id = each.value
# }
# data "aws_subnet" "protected"
data "aws_subnets" "protected_subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc_sensor_plantform.id]
}
tags = {
Tier = "protected"
}
}
# # data "aws_subnet" "protected"
# data "aws_subnets" "mqtt_protected_subnets" {
# filter {
# name = "vpc-id"
# values = [data.aws_vpc.vpc_sensor_plantform.id]
# }
# tags = {
# Tier = "mqtt"
# }
# }
# # data "aws_subnet" "protected"
# data "aws_subnet" "protected_subnet"{
# for_each = toset(data.aws_subnets.protected_subnets.ids)
# id = each.value
# }
# data "aws_subnet" "private"
data "aws_subnets" "private_subnets" {
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc_sensor_plantform.id]
}
tags = {
Tier = "private"
}
}

44
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/output.tf

@ -0,0 +1,44 @@
output "vpc_id" {
value = data.aws_vpc.vpc_sensor_plantform.id
}
# output "public_subnet" {
# value = data.aws_subnet.public_subnet
# }
# output "protected_subnet" {
# value = data.aws_subnet.protected_subnet
# }
# output "private_subnet" {
# value = data.aws_subnet.private_subnet
# }
output "public_subnet_ids" {
value = data.aws_subnets.public_subnets.ids
}
output "protected_subnet_ids" {
value = data.aws_subnets.protected_subnets.ids
}
# output "mqtt_protected_subnet_ids" {
# value = data.aws_subnets.mqtt_protected_subnets
# }
output "private_subnet_ids" {
value = data.aws_subnets.private_subnets.ids
}
# output "public_subnet_01" {
# value = data.aws_subnet.public_subnet[0].id
# }
# output "public_subnet_02" {
# value = data.aws_subnet.public_subnet[1].id
# }
# output "protected_subnet_01" {
# value = data.aws_subnet.protected_subnet[0].id
# }
# output "protected_subnet_02" {
# value = data.aws_subnet.protected_subnet[1].id
# }
output "vpc_cidr_block" {
value = data.aws_vpc.vpc_sensor_plantform.cidr_block
}
# output "subnet_cidr_blocks" {
# value = [for s in data.aws_subnet.public_subnet : s.cidr_block]
# }

69
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/network/variables.tf

@ -0,0 +1,69 @@
variable "company_name" {
type = string
default = "prod"
}
variable "vpc_name" {
type = string
}
variable "id" {
type = list(string)
default = ["01", "02", "03"]
}
variable "vpc_cidr_block" {
type = string
default = "172.200.0.0/16"
}
variable "availability_zones" {
type = list(string)
default = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
}
variable "public_subnet" {
type = list(string)
default = ["public_01", "public_02", "public_03"]
}
variable "public_subnet_cidr_block" {
type = list(string)
default = ["172.200.16.0/20", "172.200.32.0/20", "172.200.48.0/20"]
}
variable "protected_subnet" {
type = list(string)
default = ["protected_01", "protected_02", "protected_03"]
}
variable "protected_subnet_cidr_block" {
type = list(string)
default = ["172.200.64.0/20", "172.200.80.0/20", "172.200.96.0/20"]
}
variable "private_subnet" {
type = list(string)
default = ["private_01", "private_02", "private_03"]
}
variable "private_subnet_cidr_block" {
type = list(string)
default = ["172.200.112.0/20", "172.200.128.0/20", "172.200.144.0/20"]
}
# variable "public_eip" {
# type = list(string)
# default = ["172.100.10.5", "172.100.20.5", "172.100.30.5"]
# }
variable "protected_rtb_name" {
type = list(string)
default = ["protected_01_rtb", "protected_02_rtb", "protected_03_rtb"]
}
variable "aws_nat_gateway_name"{
type = list(string)
default = [ "nat_01", "nat_02", "nat_03" ]
}

145
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/init.sql

@ -0,0 +1,145 @@
/*
SQLyog - MySQL GUI v8.14
MySQL - 8.0.28 : Database - data_center_admin
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`data_center_admin` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `data_center_admin`;
/*Table structure for table `basic_company` */
DROP TABLE IF EXISTS `basic_company`;
CREATE TABLE `basic_company` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_id` bigint DEFAULT NULL,
`company_name` varchar(500) DEFAULT NULL,
`mfa_switch` int DEFAULT '0' COMMENT '谷歌mfa服务开关。0-关闭,1-开启',
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`create_time` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_company` */
insert into `basic_company`(`id`,`parent_id`,`company_name`,`mfa_switch`,`flag`,`create_time`,`modify_time`) values (1,-1,'MiniSolution',0,0,1658978002231,1658978002231);
/*Table structure for table `basic_menu` */
DROP TABLE IF EXISTS `basic_menu`;
CREATE TABLE `basic_menu` (
`id` bigint NOT NULL AUTO_INCREMENT,
`parent_menu_id` bigint DEFAULT NULL,
`menu_name` varchar(100) DEFAULT NULL,
`menu_name_en` varchar(100) DEFAULT NULL,
`menu_name_jp` varchar(100) DEFAULT NULL,
`remark` varchar(100) DEFAULT NULL,
`menu_level` int DEFAULT '1' COMMENT '菜单级别',
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`create_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_menu` */
insert into `basic_menu`(`id`,`parent_menu_id`,`menu_name`,`menu_name_en`,`menu_name_jp`,`remark`,`menu_level`,`flag`,`create_time`) values (1,-1,'项目管理','项目管理','项目管理','项目管理',1,0,1659079777164),(2,-1,'楼宇模块','楼宇模块','楼宇模块','楼宇模块',1,0,1659079777164),(3,-1,'设备模块','设备模块','设备模块','设备模块',1,0,1659079777164),(4,-1,'转发管理','转发管理','转发管理','转发管理',1,0,1659079777164),(5,-1,'数据来源管理','数据来源管理','数据来源管理','数据来源管理',1,0,1659079777164),(6,1,'添加','添加','添加','项目管理-添加',2,0,1659079777164),(7,1,'编辑','编辑','编辑','项目管理-编辑',2,0,1659079777164),(8,1,'删除','删除','删除','项目管理-删除',2,0,1659079777164),(9,1,'批量添加','批量添加','批量添加','项目管理-批量添加',2,0,1659079777164),(10,2,'楼宇管理','楼宇管理','楼宇管理','楼宇管理',2,0,1659079777164),(11,2,'楼层管理','楼层管理','楼层管理','楼层管理',2,0,1659079777164),(12,2,'房间管理','房间管理','房间管理','房间管理',2,0,1659079777164),(13,2,'资产管理','资产管理','资产管理','资产管理',2,0,1659079777164),(14,10,'添加','添加','添加','楼宇管理-添加',3,0,1659079777164),(15,10,'编辑','编辑','编辑','楼宇管理-编辑',3,0,1659079777164),(16,10,'删除','删除','删除','楼宇管理-删除',3,0,1659079777164),(17,11,'添加','添加','添加','楼层管理-添加',3,0,1659079777164),(18,11,'编辑','编辑','编辑','楼层管理-编辑',3,0,1659079777164),(19,11,'删除','删除','删除','楼层管理-删除',3,0,1659079777164),(20,12,'添加','添加','添加','房间管理-添加',3,0,1659079777164),(21,12,'编辑','编辑','编辑','房间管理-编辑',3,0,1659079777164),(22,12,'删除','删除','删除','房间管理-删除',3,0,1659079777164),(23,13,'添加','添加','添加','资产管理-添加',3,0,1659079777164),(24,13,'编辑','编辑','编辑','资产管理-编辑',3,0,1659079777164),(25,13,'删除','删除','删除','资产管理-删除',3,0,1659079777164),(26,3,'设备管理','设备管理','设备管理','设备管理',2,0,1659079777164),(27,26,'添加','添加','添加','设备管理-添加',3,0,1659079777164),(28,26,'编辑','编辑','编辑','设备管理-编辑',3,0,1659079777164),(29,26,'删除','删除','删除','设备管理-删除',3,0,1659079777164),(30,26,'批量添加','批量添加','批量添加','设备管理-批量添加',3,0,1659079777164),(31,26,'批量删除','批量删除','批量删除','设备管理-批量删除',3,0,1659079777164),(32,3,'设备类别管理','设备类别管理','设备类别管理','设备类别管理',2,0,1659079777164),(33,32,'添加','添加','添加','设备类别管理-添加',3,0,1659079777164),(34,32,'编辑','编辑','编辑','设备类别管理-编辑',3,0,1659079777164),(35,32,'删除','删除','删除','设备类别管理-删除',3,0,1659079777164),(36,4,'添加','添加','添加','转发管理-添加',3,0,1659079777164),(37,4,'编辑','编辑','编辑','转发管理-编辑',3,0,1659079777164),(38,4,'删除','删除','删除','转发管理-删除',3,0,1659079777164),(39,5,'添加','添加','添加','数据来源管理-添加',3,0,1659079777164),(40,5,'编辑','编辑','编辑','数据来源管理-编辑',3,0,1659079777164),(41,5,'删除','删除','删除','数据来源管理-删除',3,0,1659079777164);
/*Table structure for table `basic_role` */
DROP TABLE IF EXISTS `basic_role`;
CREATE TABLE `basic_role` (
`id` bigint NOT NULL AUTO_INCREMENT,
`company_id` bigint DEFAULT NULL,
`role_name` varchar(100) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
`flag` int DEFAULT '0' COMMENT '0-正常,1-删除',
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL,
`modifier_id` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_menu_relation` */
DROP TABLE IF EXISTS `basic_role_menu_relation`;
CREATE TABLE `basic_role_menu_relation` (
`role_id` bigint DEFAULT NULL,
`menu_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_role_user_relation` */
DROP TABLE IF EXISTS `basic_role_user_relation`;
CREATE TABLE `basic_role_user_relation` (
`user_id` bigint DEFAULT NULL,
`role_id` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Table structure for table `basic_user` */
DROP TABLE IF EXISTS `basic_user`;
CREATE TABLE `basic_user` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_type` int DEFAULT '0' COMMENT '0-未知,1-管理平台用户,2-普通平台用户',
`company_id` bigint NOT NULL,
`username` varchar(255) DEFAULT NULL,
`login_name` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`password_modify_time` bigint DEFAULT NULL,
`salt` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`mobile_number` varchar(255) DEFAULT NULL,
`mfa_secret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`mfa_bind` int DEFAULT '0' COMMENT '用户是否绑定了mfa设备。0-未绑定,1-已绑定',
`last_login_time` bigint DEFAULT NULL,
`flag` int NOT NULL DEFAULT '0' COMMENT '0-正常,1-删除',
`expire_time` bigint DEFAULT '4114487556000',
`create_time` bigint DEFAULT NULL,
`creator_id` bigint DEFAULT NULL,
`modify_time` bigint DEFAULT NULL,
`modifier_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*Data for the table `basic_user` */
insert into `basic_user`(`id`,`user_type`,`company_id`,`username`,`login_name`,`password`,`password_modify_time`,`salt`,`email`,`mobile_number`,`mfa_secret`,`mfa_bind`,`last_login_time`,`flag`,`expire_time`,`create_time`,`creator_id`,`modify_time`,`modifier_id`) values (1,1,1,'admin','admin','nVg+buw0YAs=',1670312031273,'09bc3a7898','1053492832@qq.com',NULL,NULL,0,1706177793183,0,4114487556000,4114487556000,NULL,1670312031273,NULL);
/*Table structure for table `login_history` */
DROP TABLE IF EXISTS `login_history`;
CREATE TABLE `login_history` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_id` bigint DEFAULT NULL,
`request_ip` varchar(255) DEFAULT NULL,
`login_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

14
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/main.tf

@ -0,0 +1,14 @@
data "aws_db_instance" "rds" {
db_instance_identifier = var.db_name
}
data "aws_elasticache_replication_group" "redis" {
replication_group_id = "replication-group-tokyo-build"
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

7
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/output.tf

@ -0,0 +1,7 @@
output "rds_address" {
value = data.aws_db_instance.rds.address
}
output "redis_address" {
value = data.aws_elasticache_replication_group.redis.primary_endpoint_address
}

8
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/rds/valiables.tf

@ -0,0 +1,8 @@
variable "project_name" {
type = string
default = "prod"
}
variable "db_name" {
type = string
}

15
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/output.tf

@ -0,0 +1,15 @@
output "security_group_sg_alb_id" {
value = data.aws_security_group.sg_alb.id
}
output "security_group_sg_internal_alb_id" {
value = data.aws_security_group.sg_internal_alb.id
}
# output "security_group_sg_nlb_id" {
# value = aws_security_group.sg_nlb.id
# }
output "security_group_sg_app_id" {
value = data.aws_security_group.sg_app.id
}
output "security_group_sg_db_id" {
value = data.aws_security_group.sg_db.id
}

430
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/security_group.tf

@ -0,0 +1,430 @@
# # Create security bation
# resource "aws_security_group" "sg_bation" {
# name = "${var.project_name}_bation_sg"
# description = "Allow bation inbound traffic"
# vpc_id = var.vpc_id
# ingress = [
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "tmp"
# from_port = 22
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 22
# }
# ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# Create security alb
# resource "aws_security_group" "sg_alb" {
# name = "${var.project_name}_alb_sg"
# description = "Allow alb inbound traffic"
# vpc_id = var.vpc_id
# ingress = [
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "https access"
# from_port = 443
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 443
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 80
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 80
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 20008
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 20008
# },
# # {
# # cidr_blocks = [
# # "0.0.0.0/0",
# # ]
# # description = "http access"
# # from_port = 8089
# # ipv6_cidr_blocks = []
# # prefix_list_ids = []
# # protocol = "tcp"
# # security_groups = []
# # self = false
# # to_port = 8089
# # },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 20015
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 20015
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 18083
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 18083
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 8201
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 8201
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 8200
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 8200
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 20016
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 20016
# },
# ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# Create security nlb
# resource "aws_security_group" "sg_nlb" {
# name = "${var.project_name}_nlb_sg"
# description = "Allow nlb inbound traffic"
# vpc_id = var.vpc_id
# ingress = [
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "https access"
# from_port = 443
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 443
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "http access"
# from_port = 80
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 80
# },
# ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# Create security app
# resource "aws_security_group" "sg_app" {
# name = "${var.project_name}_app_sg"
# description = "Allow internal ip inbound traffic"
# vpc_id = var.vpc_id
# ingress = [
# {
# cidr_blocks = [
# "${var.vpc_cidr_block}",
# ]
# description = "vpc"
# from_port = 0
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "-1"
# security_groups = []
# self = false
# to_port = 0
# }
# ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# resource "aws_security_group_rule" "sec_group_allow_bation" {
# type = "ingress"
# from_port = 22 // first part of port range
# to_port = 22 // second part of port range
# protocol = "tcp" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_app.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_bation.id}" // Which group to specify as source
# }
# resource "aws_security_group_rule" "sec_group_allow_alb" {
# type = "ingress"
# from_port = 0 // first part of port range
# to_port = 0 // second part of port range
# protocol = "-1" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_app.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_alb.id}" // Which group to specify as source
# }
# resource "aws_security_group_rule" "sec_group_allow_alb" {
# type = "ingress"
# from_port = 0 // first part of port range
# to_port = 0 // second part of port range
# protocol = "-1" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_app.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_alb.id}" // Which group to specify as source
# }
# resource "aws_security_group_rule" "sec_group_allow_nlb" {
# type = "ingress"
# from_port = 8000 // first part of port range
# to_port = 8000 // second part of port range
# protocol = "tcp" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_app.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_nlb.id}" // Which group to specify as source
# }
# Create security db
# resource "aws_security_group" "sg_db" {
# name = "${var.project_name}_db_sg"
# description = "Allow db inbound traffic"
# vpc_id = var.vpc_id
# depends_on = [aws_security_group.sg_app, aws_security_group.sg_bation]
# ingress {
# description = "mysql access"
# from_port = 3306
# to_port = 3306
# protocol = "tcp"
# # need to custm
# security_groups = [aws_security_group.sg_app.id, aws_security_group.sg_bation.id]
# }
# # ingress = [
# # {
# # cidr_blocks = [ "${var.vpc_cidr_block}", ]
# # description = "https access"
# # from_port = 443
# # ipv6_cidr_blocks = []
# # prefix_list_ids = []
# # protocol = "tcp"
# # security_groups = []
# # self = false
# # to_port = 443
# # },
# # ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# resource "aws_security_group_rule" "sec_group_allow_app_redis" {
# type = "ingress"
# from_port = 6379 // first part of port range
# to_port = 6379 // second part of port range
# protocol = "tcp" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_db.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_app.id}" // Which group to specify as source
# }
# resource "aws_security_group_rule" "sec_group_allow_bation_redis" {
# type = "ingress"
# from_port = 6379 // first part of port range
# to_port = 6379 // second part of port range
# protocol = "tcp" // Protocol, could be "tcp" "udp" etc.
# security_group_id = "${aws_security_group.sg_db.id}" // Which group to attach it to
# source_security_group_id = "${aws_security_group.sg_bation.id}" // Which group to specify as source
# }
# resource "aws_security_group" "sg_mq" {
# name = "${var.project_name}_sg_mq"
# description = "Allow bation inbound traffic"
# vpc_id = var.vpc_id
# ingress = [
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "mq access"
# from_port = 61614
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 61619
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "mq access"
# from_port = 5617
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 5617
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "mq access"
# from_port = 8883
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 8883
# },
# {
# cidr_blocks = [
# "0.0.0.0/0",
# ]
# description = "mq access"
# from_port = 8162
# ipv6_cidr_blocks = []
# prefix_list_ids = []
# protocol = "tcp"
# security_groups = []
# self = false
# to_port = 8162
# },
# ]
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# resource "aws_security_group" "sg_aurora_db" {
# name = "${var.project_name}_aurora_sg"
# description = "Allow db inbound traffic"
# vpc_id = var.vpc_id
# ingress {
# from_port = 3306
# to_port = 3306
# protocol = "tcp"
# cidr_blocks = ["0.0.0.0/0"]
# }
# egress {
# from_port = 0
# to_port = 0
# protocol = "-1"
# cidr_blocks = ["0.0.0.0/0"]
# }
# }
# alb
data "aws_security_group" "sg_alb"{
name = "${var.project_name}_alb_sg"
}
# internal alb
data "aws_security_group" "sg_internal_alb"{
name = "${var.project_name}_internal_alb_sg"
}
# ecs app sender receiver
data "aws_security_group" "sg_app"{
name = "${var.project_name}_app_sg"
}
# aurora用
data "aws_security_group" "sg_db"{
name = "${var.project_name}_db_sg"
}

10
dongjian-center-admin-controller/src/main/resources/aurora_terraform/modules/securitygroup/variables.tf

@ -0,0 +1,10 @@
variable "project_name" {
type = string
}
variable "vpc_id" {}
# variable "vpc_cidr_block" {
# type = string
# default = "172.110.0.0/16"
# }

15
dongjian-center-admin-controller/src/main/resources/aurora_terraform/output.tf

@ -0,0 +1,15 @@
output "aurora_cluster_endpoint" {
value = module.Aurora.cluster_endpoint
}
output "aurora_reader_endpoint" {
value = module.Aurora.reader_endpoint
}
output "alb_sender_dns" {
value = module.alb_elb.alb_internal_dns
}
output "alb_receiver_dns" {
value = module.alb_elb.alb_dns
}

52
dongjian-center-admin-controller/src/main/resources/aurora_terraform/variables.tf

@ -0,0 +1,52 @@
#
variable "project_name" {
type = string
default = "tokyo-build-prod"
}
# #
# variable "aws_access_config_path" {
# type = string
# default = "C:\\Users\\86150\\.aws\\config"
# }
# #
# variable "aws_access_credentials_path" {
# type = string
# default = "C:\\Users\\86150\\.aws\\credentials"
# }
variable "access_key" {
type = string
default = "placeholder_access_key"
# default = "access_key"
}
variable "secret_key" {
type = string
default = "placeholder_secret_key"
# default = "secret_key"
}
#
variable "company_name" {
type = string
default = "new-company"
}
variable "alarmRedisDatabase" {
type = string
default = "redis_db_id"
}
variable "roidAuthorization" {
type = string
default = "placeholder_roidAuthorization"
}
variable "roid2Authorization" {
type = string
default = "placeholder_roid2Authorization"
}

176
dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/main.tf

@ -0,0 +1,176 @@
provider "aws" {
region = var.region
# shared_config_files = [var.aws_access_config_path]
# shared_credentials_files = [var.aws_access_credentials_path]
# profile = "tkbuild-stg"
access_key = var.access_key
secret_key = var.secret_key
}
# modules vpc
# VPC和subnet信息
module "network" {
source = "./modules/network"
vpc_name = "${var.project_name}-vpc"
}
# security group
module "securitygroup" {
source = "./modules/securitygroup"
vpc_id = module.network.vpc_id
project_name = var.project_name
}
# redis和mysql
module "rds_redis" {
source = "./modules/rds"
project_name = var.project_name
db_name = "${var.project_name}-db"
}
# aurora
module "Aurora" {
source = "./modules/aurora"
project_name = var.project_name
company_name = var.company_name
# RDS共用subnet gp
# aurora-subnet-group = module.rds_redis.rds_subnet_gp
aurora_sg = [module.securitygroup.security_group_sg_db_id]
}
# # Active MQ
#
# module "ActiveMQ" {
# source = "./modules/mq"
# project_name = var.company_name
# subnet_mq_ids = module.network.protected_subnet_ids
# sg_mq = module.securitygroup.security_group_mq_db_id
# }
# albinternal albadmin alb nlb
module "alb_elb" {
source = "./modules/alb"
vpc_id = module.network.vpc_id
# project_name = company_name for one company
project_name = var.project_name
company_name = var.company_name
sg_alb_id = [module.securitygroup.security_group_sg_alb_id]
sg_internal_alb_id = [module.securitygroup.security_group_sg_internal_alb_id]
sub_public_ids = module.network.public_subnet_ids
sub_protect_ids = module.network.protected_subnet_ids
}
# alb添加dns解析
#
# # alb ${company_name}.kr-sensor.net
# # admin alb ${company_name}-admin.kr-sensor.net
# module "route53" {
# source = "./modules/dns"
# company_name = var.company_name
# admin_alb_name = module.alb_elb.alb_admin_domain_name
# admin_alb_zone_id = module.alb_elb.alb_admin_zone_id
# alb_name = module.alb_elb.alb_domain_name
# alb_zone_id = module.alb_elb.alb_zone_id
# }
# Image信息
module "ecr" {
source = "./modules/ecr"
repo_business_web = "tokyo-build-business"
repo_business_back = "tokyo-build-business-web"
repo_receiver = "tokyo-build-receiver"
repo_sender = "tokyo-build-sender"
repo_mqtt = "tokyo-build-mqtt"
repo_adminback = "tokyo-build-admin"
repo_adminweb = "tokyo-build-admin-web"
}
# senderrecever
module "ecs" {
source = "./modules/ecs_fargate"
# project_name = var.company_name when one company
project_name = var.project_name
company_name = var.company_name
region = var.region
autoscaling_subnet = module.network.protected_subnet_ids
sgapp_id = [ module.securitygroup.security_group_sg_app_id ]
business_name = module.ecr.business_name
business_image = module.ecr.business_uri
business_web_name = module.ecr.business-web_name
business_web_image = module.ecr.business-web_uri
sender_name = module.ecr.sender_name
sender_image = module.ecr.sender_uri
roid2Url = "https://api.public-api.kanri-roid.app/api/public/v1/targets/{targetId}/monitoring-status"
roidAlarmUrl = "https://api.public-api.kanri-roid.app/api/public/v1/problem-reports/alarm"
roidAlarmCancelUrl = "https://api.public-api.kanri-roid.app/api/public/v1/problem-reports/return-to-normal"
roidAuthorization = var.roidAuthorization
roid2Authorization = var.roid2Authorization
queryPushInfoUrl = "iothub-web.ttkdatatechbuild.com"
#kinesis stream
mqttNormalTopic = module.kinesis.aws_kinesis_stream_name
mqtt_name = module.ecr.mqtt_name
mqtt_image = module.ecr.mqtt_uri
adminback_name = module.ecr.adminback_name
adminback_image = module.ecr.adminback_uri
adminWeb_name = module.ecr.adminweb_name
adminWeb_image = module.ecr.adminweb_uri
receiver_name = module.ecr.receiver_name
receiver_image = module.ecr.receiver_uri
# redis mysql
redisHost = module.rds_redis.redis_address
redisDatabase = "0"
alarmRedisDatabase = var.alarmRedisDatabase
datasourceDNS = module.rds_redis.rds_address
# alb
receiver_tg_8200_arn = module.alb_elb.alb_8200_arn
# internal alb
sender_tg_8201_arn = module.alb_elb.alb_inter_8201_arn
sender_tg_8201_arn_suffix = module.alb_elb.alb_inter_8201_arn_suffix
dataCenterReceiverTargetUrl = module.alb_elb.alb_internal_dns
}
# kinesis stream
module "kinesis" {
source = "./modules/kinesis"
company_name = var.company_name
}
module "lambda" {
source = "./modules/lambda"
company_name = var.company_name
AURORA_USERNAME = "techsor"
AURORA_PASSWORD = "Abc#123456xyz"
AURORA_URL = module.Aurora.cluster_endpoint
AWS_ACCESS = var.access_key
AWS_SECRET = var.secret_key
subnet_ids = module.network.protected_subnet_ids
sggroup_ids = [module.securitygroup.security_group_sg_app_id]
aws_kinesis_stream_name = module.kinesis.aws_kinesis_stream_name
}
module "eventbridge_pipe" {
source = "./modules/eventbridge"
company_name = var.company_name
aws_kinesis_stream_arn = module.kinesis.aws_kinesis_stream_arn
aws_lambda_arn = module.lambda.aws_lambda_arn
}
module "glue_job" {
source = "./modules/glue_job"
project_name = var.project_name
company_name = var.company_name
aurora_endpoint = module.Aurora.cluster_endpoint
}
# teffaform init
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target
# terraform refresh

90
dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/modules/alb/main.tf

@ -0,0 +1,90 @@
# Create target group 8200
resource "aws_lb_target_group" "TG-TCP-8200" {
name = "prod-${var.company_name}-tg-8200"
port = 8200
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id
# wait before changing the state of a deregistering target from draining to unused.
deregistration_delay = 60
health_check {
interval = 30
path = "/healthcheck"
port = 8200
protocol = "HTTP"
timeout = 5
unhealthy_threshold = 2
matcher = 200
}
}
# Create ALB
resource "aws_lb" "ALB-prod-alb" {
name = "${var.company_name}-alb"
internal = false
load_balancer_type = "application"
security_groups = var.sg_alb_id
subnets = var.sub_public_ids
enable_deletion_protection = false
}
# Create ALB listener
resource "aws_lb_listener" "ALB-prod-alb-listener-8200" {
load_balancer_arn = aws_lb.ALB-prod-alb.arn
port = 8200
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.TG-TCP-8200.arn
}
}
########################
# Create target group 8201
resource "aws_lb_target_group" "TG-TCP-8201" {
name = "prod-${var.company_name}-tg-8201"
port = 8201
protocol = "HTTP"
target_type = "ip"
vpc_id = var.vpc_id
# wait before changing the state of a deregistering target from draining to unused.
deregistration_delay = 60
health_check {
interval = 30
path = "/healthcheck"
port = 8201
protocol = "HTTP"
timeout = 5
unhealthy_threshold = 2
matcher = 200
}
}
# Create internal ALB
resource "aws_lb" "ALB-prod-alb-internal" {
name = "${var.company_name}-alb-internal"
internal = true
load_balancer_type = "application"
security_groups = var.sg_internal_alb_id
subnets = var.sub_protect_ids
enable_deletion_protection = false
}
# Create ALB listener
resource "aws_lb_listener" "ALB-prod-alb-listener-8201" {
load_balancer_arn = aws_lb.ALB-prod-alb-internal.arn
port = 8201
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.TG-TCP-8201.arn
}
}
# terraform plan
# terraform apply
# terraform apply --auto-approve
# delete resource
# terraform destroy
# terraform destroy --target

19
dongjian-center-admin-controller/src/main/resources/aurora_terraform_osaka/modules/alb/output.tf

@ -0,0 +1,19 @@
output "alb_8200_arn" {
value = aws_lb_target_group.TG-TCP-8200.arn
}
output "alb_inter_8201_arn" {
value = aws_lb_target_group.TG-TCP-8201.arn
}
output "alb_inter_8201_arn_suffix" {
value = aws_lb_target_group.TG-TCP-8201.arn_suffix
}
output "alb_internal_dns" {
value = aws_lb.ALB-prod-alb-internal.dns_name
}
output "alb_dns" {
value = aws_lb.ALB-prod-alb.dns_name
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save