单表代码生成,完美了,支持强制新行,栅格定义。

This commit is contained in:
thinkgem
2018-01-27 17:12:09 +08:00
parent b44d381253
commit 7864513be0
13 changed files with 782 additions and 514 deletions

View File

@@ -228,6 +228,13 @@
</exclusions>
</dependency>
<!-- pinyin4j -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
<!-- LOGGING begin -->
<dependency>
<groupId>org.slf4j</groupId>

View File

@@ -8,6 +8,7 @@ import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.FastDateFormat;
/**
@@ -278,6 +279,44 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return new Date(time);
}
/**
* 格式化为日期范围字符串
* @param beginDate 2018-01-01
* @param endDate 2018-01-31
* @return 2018-01-01 ~ 2018-01-31
* @author ThinkGem
*/
public static String formatDateBetweenString(Date beginDate, Date endDate){
String begin = DateUtils.formatDate(beginDate);
String end = DateUtils.formatDate(endDate);
if (StringUtils.isNoneBlank(begin, end)){
return begin + " ~ " + end;
}
return StringUtils.EMPTY;
}
/**
* 解析日期范围字符串为日期对象
* @param dateString 2018-01-01 ~ 2018-01-31
* @return new Date[]{2018-01-01, 2018-01-31}
* @author ThinkGem
*/
public static Date[] parseDateBetweenString(String dateString){
Date beginDate = null; Date endDate = null;
if (StringUtils.isNotBlank(dateString)){
String[] ss = StringUtils.split(dateString, "~");
if (ss != null && ss.length == 2){
String begin = StringUtils.trim(ss[0]);
String end = StringUtils.trim(ss[1]);
if (StringUtils.isNoneBlank(begin, end)){
beginDate = DateUtils.parseDate(begin);
endDate = DateUtils.parseDate(end);
}
}
}
return new Date[]{beginDate, endDate};
}
// /**
// * @param args
// * @throws ParseException

View File

@@ -0,0 +1,106 @@
package com.jeesite.common.text;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
* 拼音工具类
* @author ThinkGem
*/
public class PinyinUtils {
// /**
// * 将字符串中的中文转化为拼音,其他字符不变
// * @param inputString
// * @return
// */
// public static String getPinyin(String inputString) {
// HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
// format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
// format.setVCharType(HanyuPinyinVCharType.WITH_V);
//
// char[] input = inputString.trim().toCharArray();
// String output = "";
//
// try {
// for (int i = 0; i < input.length; i++) {
// if (java.lang.Character.toString(input[i]).matches("[\\u4E00-\\u9FA5]+")) {
// String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);
// output += temp[0];
// } else {
// output += java.lang.Character.toString(input[i]);
// }
// }
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// }
// return output;
// }
/**
* 获取汉字串拼音首字母,替换调非法标示符字符,英文字符不变,去除空格
* @param chinese 汉字串
* @return 汉语拼音首字母
*/
public static String getFirstSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat);
if (temp != null) {
pybf.append(temp[0].charAt(0));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(arr[i]);
}
}
return pybf.toString().replaceAll("\\W", "").trim();
}
/**
* 获取汉字串全拼,英文字符不变
* @param chinese 汉字串
* @return 汉语拼音
*/
public static String getFullSpell(String chinese) {
StringBuffer pybf = new StringBuffer();
char[] arr = chinese.toCharArray();
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
try {
String[] ss = PinyinHelper.toHanyuPinyinStringArray(arr[i], defaultFormat);
if (ss != null && ss.length > 0){
pybf.append(ss[0]);
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
}
} else {
pybf.append(arr[i]);
}
}
return pybf.toString();
}
public static void main(String[] args) {
String str = "你好123世界abc,~!#$_Sdf";
// System.out.println(getPinyin(str));
System.out.println(getFirstSpell(str));
System.out.println(getFullSpell(str));
}
}

View File

@@ -1,4 +1,4 @@
.Wdate,.Wdate-date,.Wdate-datetime{background:#fff url(datePicker.gif) no-repeat right;}
.Wdate-date{width:105px!important}.Wdate-datetime{width:163px!important}
.Wdate-date{width:105px!important}.Wdate-datetime{width:147px!important}
.WdateFmtErr{font-weight:bold;color:red;}
.Wdate::-ms-clear{display:none;}

View File

@@ -1,7 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.modules.db;
package com.jeesite.modules.sys.db;
import java.io.File;
@@ -62,7 +62,7 @@ public class InitCoreData extends BaseInitDataTests {
* 清理日志表
*/
public void initLog() throws Exception{
clearTable(new Log());
clearTable(Log.class);
}
@Autowired
@@ -72,7 +72,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initConfig() throws Exception{
try{
clearTable(new Config());
clearTable(Config.class);
initExcelData(Config.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -100,7 +100,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initModule() throws Exception{
try{
clearTable(new Module());
clearTable(Module.class);
initExcelData(Module.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -129,7 +129,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initDict() throws Exception{
try{
clearTable(new DictType());
clearTable(DictType.class);
initExcelData(DictType.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -145,7 +145,7 @@ public class InitCoreData extends BaseInitDataTests {
}
});
clearTable(new DictData());
clearTable(DictData.class);
initExcelData(DictData.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -172,9 +172,9 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initRole() throws Exception{
try{
clearTable(new Role());
clearTable(new RoleMenu());
clearTable(new RoleDataScope());
clearTable(Role.class);
clearTable(RoleMenu.class);
clearTable(RoleDataScope.class);
initExcelData(Role.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -203,8 +203,8 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initMenu() throws Exception{
try{
clearTable(new Menu());
clearTable(new RoleMenu());
clearTable(Menu.class);
clearTable(RoleMenu.class);
initExcelData(Menu.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -235,9 +235,9 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initUser() throws Exception{
try{
clearTable(new User());
clearTable(new UserRole());
clearTable(new UserDataScope());
clearTable(User.class);
clearTable(UserRole.class);
clearTable(UserDataScope.class);
initExcelData(User.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -265,7 +265,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initArea() throws Exception{
try{
clearTable(new Area());
clearTable(Area.class);
initExcelData(Area.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -292,7 +292,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initOffice() throws Exception{
try{
clearTable(new Office());
clearTable(Office.class);
initExcelData(Office.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -319,8 +319,8 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initCompany() throws Exception{
try{
clearTable(new Company());
clearTable(new CompanyOffice());
clearTable(Company.class);
clearTable(CompanyOffice.class);
initExcelData(Company.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -347,7 +347,7 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initPost() throws Exception{
try{
clearTable(new Post());
clearTable(Post.class);
initExcelData(Post.class, new MethodCallback() {
@Override
public Object execute(Object... params) {
@@ -374,8 +374,8 @@ public class InitCoreData extends BaseInitDataTests {
*/
public void initEmpUser() throws Exception{
try{
clearTable(new Employee());
clearTable(new EmployeePost());
clearTable(Employee.class);
clearTable(EmployeePost.class);
initExcelData(EmpUser.class, new MethodCallback() {
@Override
public Object execute(Object... params) {

View File

@@ -5,22 +5,22 @@
# 数据库连接
jdbc:
# Oracle 数据库配置
type: oracle
driver: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@127.0.0.1:1521/orcl
username: jeesite
password: jeesite
testSql: SELECT 1 FROM DUAL
# Mysql 数据库配置
# # Mysql 数据库配置
# type: mysql
# driver: com.mysql.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/jeesite?useUnicode=true&characterEncoding=utf-8
# url: jdbc:mysql://127.0.0.1:3306/jeesite4?useUnicode=true&characterEncoding=utf-8
# username: root
# password: 123456
# testSql: SELECT 1
# Oracle 数据库配置
# type: oracle
# driver: oracle.jdbc.driver.OracleDriver
# url: jdbc:oracle:thin:@127.0.0.1:1521/orcl
# username: jeesite
# password: jeesite
# testSql: SELECT 1
# testSql: SELECT 1 FROM DUAL
# Sql Server 数据库配置
# type: mssql

View File

@@ -11,7 +11,7 @@ DROP TABLE IF EXISTS test_tree;
/* Create Tables */
-- test_data
-- 测试数据
CREATE TABLE test_data
(
id varchar(64) NOT NULL COMMENT '编号',
@@ -22,10 +22,11 @@ CREATE TABLE test_data
test_radio varchar(10) COMMENT '单选框',
test_checkbox varchar(200) COMMENT '复选框',
test_date timestamp COMMENT '日期选择',
test_datetime timestamp COMMENT '日期时间选择',
test_datetime timestamp COMMENT '日期时间',
test_user_code varchar(64) COMMENT '用户选择',
test_office_code varchar(64) COMMENT '部门选择',
test_company_code varchar(64) COMMENT '公司选择',
test_area_code varchar(64) COMMENT '区域选择',
status char(1) DEFAULT '0' NOT NULL COMMENT '状态0正常 1删除 2停用',
create_by varchar(64) NOT NULL COMMENT '创建者',
create_date timestamp NOT NULL COMMENT '创建时间',
@@ -33,10 +34,10 @@ CREATE TABLE test_data
update_date timestamp NOT NULL COMMENT '更新时间',
remarks varchar(500) COMMENT '备注信息',
PRIMARY KEY (id)
) COMMENT = 'test_data';
) ENGINE = InnoDB COMMENT = '测试数据' DEFAULT CHARACTER SET utf8;
-- test_data_child
-- 测试数据子表
CREATE TABLE test_data_child
(
id varchar(64) NOT NULL COMMENT '编号',
@@ -49,15 +50,16 @@ CREATE TABLE test_data_child
test_radio varchar(10) COMMENT '单选框',
test_checkbox varchar(200) COMMENT '复选框',
test_date timestamp COMMENT '日期选择',
test_datetime timestamp COMMENT '日期时间选择',
test_datetime timestamp COMMENT '日期时间',
test_user_code varchar(64) COMMENT '用户选择',
test_office_code varchar(64) COMMENT '部门选择',
test_company_code varchar(64) COMMENT '公司选择',
test_area_code varchar(64) COMMENT '区域选择',
PRIMARY KEY (id)
) COMMENT = 'test_data_child';
) ENGINE = InnoDB COMMENT = '测试数据子表' DEFAULT CHARACTER SET utf8;
-- test_tree
-- 测试树表
CREATE TABLE test_tree
(
id varchar(64) NOT NULL COMMENT '编号',
@@ -76,7 +78,7 @@ CREATE TABLE test_tree
update_date timestamp NOT NULL COMMENT '更新时间',
remarks varchar(500) COMMENT '备注信息',
PRIMARY KEY (id)
) COMMENT = 'test_tree';
) ENGINE = InnoDB COMMENT = '测试树表' DEFAULT CHARACTER SET utf8;

View File

@@ -24,7 +24,8 @@ CREATE TABLE test_data
test_datetime timestamp,
test_user_code varchar2(64),
test_office_code varchar2(64),
test_company_code varchar2(64),
test_area_code varchar2(64),
test_area_name nvarchar2(100),
status char(1) DEFAULT '0' NOT NULL,
create_by varchar2(64) NOT NULL,
create_date timestamp NOT NULL,
@@ -51,7 +52,8 @@ CREATE TABLE test_data_child
test_datetime timestamp,
test_user_code varchar2(64),
test_office_code varchar2(64),
test_company_code varchar2(64),
test_area_code varchar2(64),
test_area_name nvarchar2(100),
PRIMARY KEY (id)
);
@@ -93,7 +95,8 @@ COMMENT ON COLUMN test_data.test_date IS '日期选择';
COMMENT ON COLUMN test_data.test_datetime IS '日期时间';
COMMENT ON COLUMN test_data.test_user_code IS '用户选择';
COMMENT ON COLUMN test_data.test_office_code IS '部门选择';
COMMENT ON COLUMN test_data.test_company_code IS '公司选择';
COMMENT ON COLUMN test_data.test_area_code IS '区域选择';
COMMENT ON COLUMN test_data.test_area_name IS '区域名称';
COMMENT ON COLUMN test_data.status IS '状态0正常 1删除 2停用';
COMMENT ON COLUMN test_data.create_by IS '创建者';
COMMENT ON COLUMN test_data.create_date IS '创建时间';
@@ -114,7 +117,8 @@ COMMENT ON COLUMN test_data_child.test_date IS '日期选择';
COMMENT ON COLUMN test_data_child.test_datetime IS '日期时间';
COMMENT ON COLUMN test_data_child.test_user_code IS '用户选择';
COMMENT ON COLUMN test_data_child.test_office_code IS '部门选择';
COMMENT ON COLUMN test_data_child.test_company_code IS '公司选择';
COMMENT ON COLUMN test_data_child.test_area_code IS '区域选择';
COMMENT ON COLUMN test_data_child.test_area_name IS '区域名称';
COMMENT ON TABLE test_tree IS '测试树表';
COMMENT ON COLUMN test_tree.id IS '编号';
COMMENT ON COLUMN test_tree.parent_code IS '父级编号';

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,14 @@
# 数据库连接
jdbc:
# Mysql 数据库配置
# type: mysql
# driver: com.mysql.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/jeesite4?useUnicode=true&characterEncoding=utf-8
# username: root
# password: 123456
# testSql: SELECT 1
# Oracle 数据库配置
type: oracle
driver: oracle.jdbc.driver.OracleDriver
@@ -13,15 +21,7 @@ jdbc:
username: jeesite
password: jeesite
testSql: SELECT 1 FROM DUAL
# Mysql 数据库配置
# type: mysql
# driver: com.mysql.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/jeesite?useUnicode=true&characterEncoding=utf-8
# username: jeesite
# password: jeesite
# testSql: SELECT 1
# Redis 配置
redis:

View File

@@ -5,7 +5,7 @@ package com.jeesite.test;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Commit;
import org.springframework.test.annotation.Rollback;
import com.jeesite.modules.config.Application;
@@ -15,23 +15,23 @@ import com.jeesite.modules.config.Application;
* @version 2017-10-22
*/
@SpringBootTest(classes=Application.class)
@Commit
public class InitCoreData extends com.jeesite.modules.db.InitCoreData {
@Rollback(false)
public class InitCoreData extends com.jeesite.modules.sys.db.InitCoreData {
@Test
public void initCoreData() throws Exception{
initLog();
initConfig();
initModule();
initDict();
initRole();
initMenu();
initUser();
// initConfig();
// initModule();
// initDict();
// initRole();
// initMenu();
// initUser();
// initArea();
initOffice();
initCompany();
initPost();
initEmpUser();
// initOffice();
// initCompany();
// initPost();
// initEmpUser();
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.test;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import com.jeesite.modules.config.Application;
/**
* 初始化代码生成表测试数据
* @author ThinkGem
* @version 2017-10-22
*/
@SpringBootTest(classes=Application.class)
@Rollback(false)
public class InitGenData extends com.jeesite.modules.gen.db.InitGenData {
@Test
public void initGenData() throws Exception{
initGenTestData();
initGenTreeData();
}
}