赞
踩
jeecg-boot-module-system模块下,这里先看application这几个环境配置文件
application.yml用于决定哪个环境有效
dev,prod,test分别代表开发、生产、测试环境,可根据实际需要调整环境配置内容
在application.yml里配置环境,这里选择的dev环境,所以在修改数据源的时候,修改application-dev.yml文件
spring:
application:
name: jeecg-system
profiles:
active: dev
在datasource结构下,添加新的数据源连接并命名,名字应具有可标志性和唯一性,便于后续引用
....... datasource: master: url: jdbc:mysql://127.0.0.1:3306/zxy?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver # 添加多个数据源 postgres: # 这里使用currentSchema来决定当前使用的schema # 根据需要,不写也可以 url: jdbc:postgresql://127.0.0.1:5432/postgres?currentSchema=zxy username: postgres password: postgres driver-class-name: org.postgresql.Driver .....
在多数据源环境下,默认使用我们第一个数据源,也就是master数据源。
当我们想要使用其他数据源时,需要在ServiceImpl文件中添加注解
注解模板为@DS("datasource_name")
比如我刚才添加的第二个数据源名称为postgres,那么我在使用的时候就需要添加注解@DS("postgres")
常用maven配置文件
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:\software\apache-maven-3.6.1\repository</localRepository> <pluginGroups></pluginGroups> <proxies></proxies> <servers></servers> <mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>*,!jeecg,!jeecg-snapshots,!getui-nexus</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror> <!-- 阿里云仓库 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <!-- 中央仓库1 --> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> <!-- 中央仓库2 --> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> </mirrors> <profiles> <profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile> </profiles> </settings>
CREATE TABLE sys_link_table (
id int NULL,
pid int NULL,
name varchar(64) null
);
id | pid | name |
---|---|---|
1 | 全国 | |
2 | 1 | 浙江省 |
3 | 2 | 杭州市 |
4 | 2 | 宁波市 |
5 | 1 | 江苏省 |
6 | 5 | 南京市 |
7 | 5 | 苏州市 |
8 | 1 | 广东省 |
9 | 8 | 广州市 |
10 | 8 | 珠海市 |
新增字段省:province
新增字段市:city
页面属性->province字段组件类型设置为联动组件
校验字段-> province字段字典table填如下json :
{
table: "sys_link_table",
txt: "name",
key: "id",
linkField: "city",
idField: "id",
pidField: "pid",
condition:"pid = '1'"
}
名称 | 描述 |
---|---|
table | 数据库表名 |
txt | 控件显示的值 |
key | 控件需要存储的值 |
linkField | 级联组件的其他字段名称,上例配置了市,区字段名 |
idField | 数据的标识 |
pidField | 上下级关系的表示字段 |
condition | 联动组件 第一个下拉框的数据查询条件 |
同步数据库后,会根据当前配置表结构,在数据库中创建对应表
功能测试方便调试表单内容
当新增数据时,如选择浙江省,则根据联动效果,会提供浙江省对应的市下拉框,提供选择
因为字典表是sys_link_table
,表单对应的表是sys_link_test
,
在选择表单中选择省的时候,会从sys_link_table
中取name作为值。
当联动到市的时候,会取对应的id作为值。
如上图所示,字段“市"的值是数字,查看不太方便。
可以选择使用字典,匹配对应的值。
创建字典sys_link_city
sys_link_table
中的id作为数据值,name作为名称
将新增的字典名sys_link_city
,配置到city字段的字典Code处
字段city配置好字典后,再次查看已经比较清晰。
注解: @Excel
参数:mergeVertical,参数设置为Boolean类型,默认为false。当设置为true时,可以纵向合并内容相同的单元格
介绍:每个类别下有多个型号,每个型号会有对应的数量,在字段合计时会根据类别进行合计。
需求:希望表单在导出的时候,"合计"列能够合并单元格
修改对应的表单的实体类,修改该字段的Excel注释
mergeVertical = true
在字段添加合并单元格后,再次导出表单可以发现该字段已经自动合并了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。