Browse Source

Merge remote-tracking branch 'origin/dev_bugfix' into dev_bugfix

master
sunyuchao 5 years ago
parent
commit
362ba6381f
  1. 6
      epmet-commons/epmet-commons-mybatis/pom.xml
  2. 8
      epmet-module/gov-access/gov-access-server/pom.xml
  3. 8
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java
  4. 15
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/DatabaseProperties.java
  5. 29
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/DbMigrationConfig.java
  6. 64
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/DemoController.java
  7. 11
      epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml
  8. 4
      epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/V2__DemoSql.sql
  9. 0
      epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/epmet_gov_access.sql
  10. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

6
epmet-commons/epmet-commons-mybatis/pom.xml

@ -70,6 +70,12 @@
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
<!--flyway 数据库迁移工具-->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
</dependencies>
<build>

8
epmet-module/gov-access/gov-access-server/pom.xml

@ -112,7 +112,7 @@
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_gov_access?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet_gov_access_user</spring.datasource.druid.username>
<spring.datasource.druid.username>epmet_gov_org_user</spring.datasource.druid.username>
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
@ -127,6 +127,9 @@
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip/>
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>false</spring.flyway.enabled>
</properties>
</profile>
<profile>
@ -157,6 +160,9 @@
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip/>
<!--flyway migration 数据库迁移工具-->
<spring.flyway.enabled>true</spring.flyway.enabled>
</properties>
</profile>
</profiles>

8
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/GovAccessApplication.java

@ -6,15 +6,15 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
//@EnableConfigurationProperties(value = {DatabaseProperties.class})
public class GovAccessApplication {
public static void main(String[] args) {
SpringApplication.run(GovAccessApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(GovAccessApplication.class, args);
}
}

15
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/DatabaseProperties.java

@ -0,0 +1,15 @@
//package com.epmet.config;
//
//import lombok.Data;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//
//@ConfigurationProperties(prefix = "spring.datasource.druid")
//@Data
//public class DatabaseProperties {
//
// private String driverClassName;
// private String url;
// private String username;
// private String password;
//
//}

29
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/DbMigrationConfig.java

@ -0,0 +1,29 @@
//package com.epmet.config;
//
//import org.flywaydb.core.Flyway;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import javax.annotation.PostConstruct;
//
///**
// * 数据库迁移配置
// */
//@Configuration
//public class DbMigrationConfig {
//
// @Autowired
// private DatabaseProperties databaseProperties;
//
// @PostConstruct
// public void migrate() {
// Flyway flyway = Flyway.configure().dataSource(
// databaseProperties.getUrl(),
// databaseProperties.getUsername(),
// databaseProperties.getPassword())
// .baselineOnMigrate(true)
// .load();
//
// flyway.migrate();
// }
//
//}

64
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/DemoController.java

@ -0,0 +1,64 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
@RestController
@RequestMapping("demo")
public class DemoController {
@PostMapping("adduser")
public Result addUser(@RequestBody UserFormDTO form) {
ValidatorUtils.validateEntity(form, UserFormDTO.AddUserShowGroup.class, UserFormDTO.AddUserInternalGroup.class);
System.out.println(form);
return new Result();
}
}
@Data
class UserFormDTO {
//>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>>
/**
* 添加用户操作的内部异常分组
* 出现错误会提示给前端7000错误码返回信息为服务器开小差...
*/
public interface AddUserInternalGroup {}
/**
* 添加用户操作的用户可见异常分组
* 该分组用于校验需要返回给前端错误信息提示的列需要继承CustomerClientShowGroup
* 返回错误码为8999提示信息为DTO中具体的列的校验注解message的内容
*/
public interface AddUserShowGroup extends CustomerClientShowGroup {}
// <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<<
/**
* 该字段在查询用户和添加用户的时候都要校验所以在groups中会添加2个分组校验器会优先校验继承了CustomerClientShowGroup
* 的分组
* 1.该分组校验出错直接将信息返回客户端(多个字段有错误多个字段的错误信息
* 拼接起来逗号分隔,详见ValidatorUtils#validadtorEntity()方法)
* 2.该分组校验成功则继续往下校验内部错误若出现内部错误则返回7000,服务器开小差...
*/
@NotBlank(message = "请输入姓名信息", groups = { AddUserInternalGroup.class, AddUserShowGroup.class })
private String name;
/**
* 用户别名只在内部传输因此它所属的分组不能继承CustomerClientShowGroup
*/
@NotBlank(message = "用户别名不能为空", groups = { AddUserInternalGroup.class })
private String alias;
@NotBlank(message = "请输入地址信息", groups = { AddUserShowGroup.class })
private String address;
}

11
epmet-module/gov-access/gov-access-server/src/main/resources/bootstrap.yml

@ -50,6 +50,17 @@ spring:
# - data-id: common.yaml
# group: ${spring.cloud.nacos.config.group}
# refresh: true
# 数据迁移工具flyway
flyway:
enabled: @spring.flyway.enabled@
locations: classpath:db/migration
url: @spring.datasource.druid.url@
user: @spring.datasource.druid.username@
password: @spring.datasource.druid.password@
baseline-on-migrate: true
management:
endpoints:
web:

4
epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/V2__DemoSql.sql

@ -0,0 +1,4 @@
-- CREATE TABLE epmet_gov_access.device_t (
-- device_id bigint(11) primary KEY auto_increment,
-- device_name varchar(20) NOT NULL
-- )

0
epmet-module/gov-access/gov-access-server/src/main/resources/db.migration/epmet_gov_access.sql → epmet-module/gov-access/gov-access-server/src/main/resources/db/migration/epmet_gov_access.sql

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -281,7 +281,7 @@ public class AgencyServiceImpl implements AgencyService {
CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(form, CustomerAgencyEntity.class);
entity.setAllParentName("");
entity.setOrganizationName(form.getAgencyName());
entity.setPids("0");
entity.setPids("");
entity.setPid("0");
entity.setTotalUser(0);
entity.setCustomerId(form.getCustomerId());

Loading…
Cancel
Save