Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
appbuild
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
appbuild
Commits
098b6102
Commit
098b6102
authored
Oct 18, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加apipost生成接口文档逻辑
parent
a0bf845e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
34 deletions
+97
-34
appbuild-manager/src/main/java/com/mortals/xhx/base/framework/config/GenConfig.java
...java/com/mortals/xhx/base/framework/config/GenConfig.java
+67
-23
appbuild-manager/src/main/java/com/mortals/xhx/base/system/gentable/service/impl/GentableServiceImpl.java
...ase/system/gentable/service/impl/GentableServiceImpl.java
+1
-0
appbuild-manager/src/main/java/com/mortals/xhx/base/system/user/model/UserEntity.java
...va/com/mortals/xhx/base/system/user/model/UserEntity.java
+5
-0
appbuild-manager/src/main/java/com/mortals/xhx/common/key/GenConstants.java
...rc/main/java/com/mortals/xhx/common/key/GenConstants.java
+3
-1
appbuild-manager/src/main/java/com/mortals/xhx/common/utils/GenUtils.java
.../src/main/java/com/mortals/xhx/common/utils/GenUtils.java
+13
-6
appbuild-manager/src/main/resources/generator.yml
appbuild-manager/src/main/resources/generator.yml
+5
-3
appbuild-manager/src/main/resources/template/java/webBody.java.ftl
...manager/src/main/resources/template/java/webBody.java.ftl
+3
-1
No files found.
appbuild-manager/src/main/java/com/mortals/xhx/base/framework/config/GenConfig.java
View file @
098b6102
...
...
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
/**
* 读取代码生成相关配置
*
...
...
@@ -12,42 +13,60 @@ import org.springframework.stereotype.Component;
*/
@Component
@ConfigurationProperties
(
prefix
=
"gen"
)
@PropertySource
(
value
=
{
"classpath:generator.yml"
})
@PropertySource
(
value
=
{
"classpath:generator.yml"
})
public
class
GenConfig
{
/** 作者 */
/**
* 作者
*/
public
static
String
author
;
/** 生成包路径 */
/**
* 生成包路径
*/
public
static
String
packageName
;
/** 生成moduleName */
/**
* 系统包路径
*/
public
static
String
systemPackageName
=
"com.mortals.xhx.base"
;
/**
* 生成moduleName
*/
public
static
String
moduleName
;
/** 自动去除表前缀,默认是false */
/**
* 系统module名称
*/
public
static
String
systemModuleName
=
"system"
;
/**
* 自动去除表前缀,默认是false
*/
public
static
boolean
autoRemovePre
;
/** 表前缀(类名不会包含表前缀) */
/**
* 表前缀(类名不会包含表前缀)
*/
public
static
String
tablePrefix
;
public
static
String
getAuthor
()
{
public
static
String
systemTable
=
"mortals_xhx_user,mortals_xhx_valid_code,mortals_xhx_uploadfile,mortals_xhx_task,mortals_xhx_table_index,mortals_xhx_role,mortals_xhx_role_auth,mortals_xhx_role_user,mortals_xhx_menu,mortals_xhx_oper_log,mortals_xhx_param,mortals_xhx_idgenerator,mortals_xhx_area"
;
public
static
String
getAuthor
()
{
return
author
;
}
@Value
(
"${author}"
)
public
void
setAuthor
(
String
author
)
{
public
void
setAuthor
(
String
author
)
{
GenConfig
.
author
=
author
;
}
public
static
String
getPackageName
()
{
public
static
String
getPackageName
()
{
return
packageName
;
}
@Value
(
"${packageName}"
)
public
void
setPackageName
(
String
packageName
)
{
public
void
setPackageName
(
String
packageName
)
{
GenConfig
.
packageName
=
packageName
;
}
...
...
@@ -55,30 +74,55 @@ public class GenConfig {
public
static
String
getModuleName
()
{
return
moduleName
;
}
@Value
(
"${moduleName}"
)
public
void
setModuleName
(
String
moduleName
)
{
public
void
setModuleName
(
String
moduleName
)
{
GenConfig
.
moduleName
=
moduleName
;
}
public
static
boolean
getAutoRemovePre
()
{
public
static
boolean
getAutoRemovePre
()
{
return
autoRemovePre
;
}
@Value
(
"${autoRemovePre}"
)
public
void
setAutoRemovePre
(
boolean
autoRemovePre
)
{
public
void
setAutoRemovePre
(
boolean
autoRemovePre
)
{
GenConfig
.
autoRemovePre
=
autoRemovePre
;
}
public
static
String
getTablePrefix
()
{
public
static
String
getTablePrefix
()
{
return
tablePrefix
;
}
@Value
(
"${tablePrefix}"
)
public
void
setTablePrefix
(
String
tablePrefix
)
{
public
void
setTablePrefix
(
String
tablePrefix
)
{
GenConfig
.
tablePrefix
=
tablePrefix
;
}
public
static
String
getSystemTable
()
{
return
systemTable
;
}
@Value
(
"${systemTable}"
)
public
static
void
setSystemTable
(
String
systemTable
)
{
GenConfig
.
systemTable
=
systemTable
;
}
public
static
String
getSystemPackageName
()
{
return
systemPackageName
;
}
@Value
(
"${systemPackageName}"
)
public
static
void
setSystemPackageName
(
String
systemPackageName
)
{
GenConfig
.
systemPackageName
=
systemPackageName
;
}
public
static
String
getSystemModuleName
()
{
return
systemModuleName
;
}
@Value
(
"${systemModuleName}"
)
public
static
void
setSystemModuleName
(
String
systemModuleName
)
{
GenConfig
.
systemModuleName
=
systemModuleName
;
}
}
appbuild-manager/src/main/java/com/mortals/xhx/base/system/gentable/service/impl/GentableServiceImpl.java
View file @
098b6102
...
...
@@ -114,6 +114,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
);
throw
new
AppException
(
"导入失败:"
+
e
.
getMessage
());
}
}
...
...
appbuild-manager/src/main/java/com/mortals/xhx/base/system/user/model/UserEntity.java
View file @
098b6102
...
...
@@ -352,6 +352,11 @@ public class UserEntity extends UserEntityExt implements IUser {
return
""
;
}
@Override
public
String
getAreaCodes
()
{
return
""
;
}
/**
* 设置 站点id
* @param siteId
...
...
appbuild-manager/src/main/java/com/mortals/xhx/common/key/GenConstants.java
View file @
098b6102
...
...
@@ -197,7 +197,9 @@ public class GenConstants {
*/
public
static
final
Integer
NOREQUIRE
=
0
;
/**
* MySQL默认关键字
*/
public
static
final
String
[]
MYSQL_KEYWORDS
=
{
"add"
,
"all"
,
"alter"
,
"analyze"
,
"and"
,
"as"
,
"asc"
,
"asensitive"
,
"before"
,
"between"
,
"bigint"
,
"binary"
,
"blob"
,
"both"
,
"by"
,
"call"
,
"cascade"
,
"case"
,
"change"
,
"char"
,
"character"
,
"check"
,
"collate"
,
"column"
,
"condition"
,
"connection"
,
"constraint"
,
"continue"
,
"convert"
,
"create"
,
"cross"
,
"current_date"
,
"current_time"
,
"current_timestamp"
,
"current_user"
,
"cursor"
,
"database"
,
"databases"
,
"day_hour"
,
"day_microsecond"
,
"day_minute"
,
"day_second"
,
"dec"
,
"decimal"
,
"declare"
,
"default"
,
"delayed"
,
"delete"
,
"desc"
,
"describe"
,
"deterministic"
,
"distinct"
,
"distinctrow"
,
"div"
,
"double"
,
"drop"
,
"dual"
,
"each"
,
"else"
,
"elseif"
,
"enclosed"
,
"escaped"
,
"exists"
,
"exit"
,
"explain"
,
"false"
,
"fetch"
,
"float"
,
"float4"
,
"float8"
,
"for"
,
"force"
,
"foreign"
,
"from"
,
"fulltext"
,
"goto"
,
"grant"
,
"group"
,
"having"
,
"high_priority"
,
"hour_microsecond"
,
"hour_minute"
,
"hour_second"
,
"if"
,
"ignore"
,
"in"
,
"index"
,
"infile"
,
"inner"
,
"inout"
,
"insensitive"
,
"insert"
,
"int"
,
"int1"
,
"int2"
,
"int3"
,
"int4"
,
"int8"
,
"integer"
,
"interval"
,
"into"
,
"is"
,
"iterate"
,
"join"
,
"key"
,
"keys"
,
"kill"
,
"label"
,
"leading"
,
"leave"
,
"left"
,
"like"
,
"limit"
,
"linear"
,
"lines"
,
"load"
,
"localtime"
,
"localtimestamp"
,
"lock"
,
"long"
,
"longblob"
,
"longtext"
,
"loop"
,
"low_priority"
,
"match"
,
"mediumblob"
,
"mediumint"
,
"mediumtext"
,
"middleint"
,
"minute_microsecond"
,
"minute_second"
,
"mod"
,
"modifies"
,
"natural"
,
"not"
,
"no_write_to_binlog"
,
"null"
,
"numeric"
,
"on"
,
"optimize"
,
"option"
,
"optionally"
,
"or"
,
"order"
,
"out"
,
"outer"
,
"outfile"
,
"precision"
,
"primary"
,
"procedure"
,
"purge"
,
"raid0"
,
"range"
,
"read"
,
"reads"
,
"real"
,
"references"
,
"regexp"
,
"release"
,
"rename"
,
"repeat"
,
"replace"
,
"require"
,
"restrict"
,
"return"
,
"revoke"
,
"right"
,
"rlike"
,
"schema"
,
"schemas"
,
"second_microsecond"
,
"select"
,
"sensitive"
,
"separator"
,
"set"
,
"show"
,
"smallint"
,
"spatial"
,
"specific"
,
"sql"
,
"sqlexception"
,
"sqlstate"
,
"sqlwarning"
,
"sql_big_result"
,
"sql_calc_found_rows"
,
"sql_small_result"
,
"ssl"
,
"starting"
,
"straight_join"
,
"table"
,
"terminated"
,
"then"
,
"tinyblob"
,
"tinyint"
,
"tinytext"
,
"to"
,
"trailing"
,
"trigger"
,
"true"
,
"undo"
,
"union"
,
"unique"
,
"unlock"
,
"unsigned"
,
"update"
,
"usage"
,
"use"
,
"using"
,
"utc_date"
,
"utc_time"
,
"utc_timestamp"
,
"values"
,
"varbinary"
,
"varchar"
,
"varcharacter"
,
"varying"
,
"when"
,
"where"
,
"while"
,
"with"
,
"write"
,
"x509"
,
"xor"
,
"year_month"
,
"zerofill"
};
public
static
final
Set
<
String
>
KEYWORDS_SET
=
new
HashSet
<>(
Arrays
.
asList
(
MYSQL_KEYWORDS
));
...
...
appbuild-manager/src/main/java/com/mortals/xhx/common/utils/GenUtils.java
View file @
098b6102
...
...
@@ -11,10 +11,7 @@ import com.mortals.xhx.common.key.GenConstants;
import
org.apache.commons.lang3.RegExUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -24,14 +21,24 @@ import java.util.stream.Collectors;
* @date: 2021/9/28 15:35
*/
public
class
GenUtils
{
/**
* 初始化表信息
*/
public
static
void
initTable
(
GentableEntity
genTable
,
String
operName
)
{
genTable
.
setClassName
(
convertClassName
(
genTable
.
getTableName
()));
//packageName
genTable
.
setPackageName
(
GenConfig
.
getPackageName
());
genTable
.
setModuleName
(
GenConfig
.
getModuleName
());
//判断表是否为系统表,如果是
Set
<
String
>
systemTableSet
=
Arrays
.
asList
(
GenConfig
.
getSystemTable
().
split
(
","
)).
stream
().
collect
(
Collectors
.
toSet
());
if
(
systemTableSet
.
contains
(
genTable
.
getTableName
())){
genTable
.
setPackageName
(
GenConfig
.
getSystemPackageName
());
genTable
.
setModuleName
(
GenConfig
.
getSystemModuleName
());
}
else
{
genTable
.
setPackageName
(
GenConfig
.
getPackageName
());
genTable
.
setModuleName
(
GenConfig
.
getModuleName
());
}
genTable
.
setBusinessName
(
getBusinessName
(
genTable
.
getTableName
()));
genTable
.
setFunctionName
(
replaceText
(
genTable
.
getTableComment
()));
genTable
.
setFunctionAuthor
(
GenConfig
.
getAuthor
());
...
...
appbuild-manager/src/main/resources/generator.yml
View file @
098b6102
# 代码生成
gen
:
gen
:
# 作者
author
:
zxfei
# 默认生成包路径
packageName
:
com.mortals.xhx
systemPackageName
:
com.mortals.xhx.base
# module名称
moduleName
:
module
systemModuleName
:
system
# 自动去除表前缀,默认是false
autoRemovePre
:
true
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix
:
sys_,mortals_xhx_,mortals_iot_,mortals_stp_,mortals_sys_
\ No newline at end of file
tablePrefix
:
sys_,mortals_xhx_,mortals_iot_,mortals_stp_,mortals_sys_,mortals_etl_,mortals_
systemTable
:
mortals_xhx_user,mortals_xhx_valid_code,mortals_xhx_uploadfile,mortals_xhx_task,mortals_xhx_table_index,mortals_xhx_role,mortals_xhx_role_auth,mortals_xhx_role_user,mortals_xhx_menu,mortals_xhx_oper_log,mortals_xhx_param,mortals_xhx_idgenerator,mortals_xhx_area
\ No newline at end of file
appbuild-manager/src/main/resources/template/java/webBody.java.ftl
View file @
098b6102
...
...
@@ -26,6 +26,7 @@ import java.util.Arrays;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
org
.
springframework
.
web
.
multipart
.
MultipartFile
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.*;
import
com
.
mortals
.
xhx
.
common
.
code
.*;
/**
*
*
${
functionName
}
...
...
@@ -48,7 +49,8 @@ public class ${ClassName}Controller extends BaseCRUDJsonBodyMappingController<${
protected
void
init
(
Map
<
String
,
Object
>
model
,
Context
context
)
{
<#
list
columns
as
column
>
<#
if
column
.
columnType
?
contains
(
"tinyint"
)
||
column
.
htmlType
==
3
||
column
.
htmlType
==
5
>
this
.
addDict
(
model
,
"${column.javaField}"
,
paramService
.
getParamBySecondOrganize
(
"${ClassName}"
,
"${column.javaField}"
));
<#--
this
.
addDict
(
model
,
"${column.javaField}"
,
paramService
.
getParamBySecondOrganize
(
"${ClassName}"
,
"${column.javaField}"
));-->
this
.
addDict
(
model
,
"${column.javaField}"
,
${
column
.
javaField
?
cap_first
}
Enum
.
getEnumMap
());
</#
if
>
</#
list
>
super
.
init
(
model
,
context
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment