Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Springboot Plus
Commits
321361c9
"jetbrains:/idea/checkout/git" did not exist on "09d220a27b164917971191000661659d38d4f876"
Commit
321361c9
authored
Feb 21, 2018
by
xiandafu
Browse files
init
parent
2971e3f1
Changes
449
Hide whitespace changes
Inline
Side-by-side
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreFunction.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
public
class
CoreFunction
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
//创建时间
protected
Date
createTime
;
private
String
accessUrl
;
@NotBlank
private
String
code
;
@NotBlank
private
String
name
;
@NotBlank
private
Long
parentId
;
@Dict
(
type
=
CoreDictType
.
FUNCTION_TYPE
)
@NotBlank
private
String
type
=
"FN0"
;
public
String
getAccessUrl
(){
return
accessUrl
;
}
public
void
setAccessUrl
(
String
accessUrl
){
this
.
accessUrl
=
accessUrl
;
}
public
String
getCode
(){
return
code
;
}
public
void
setCode
(
String
code
){
this
.
code
=
code
;
}
public
String
getName
(){
return
name
;
}
public
void
setName
(
String
name
){
this
.
name
=
name
;
}
public
Date
getCreateTime
(){
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
){
this
.
createTime
=
createTime
;
}
public
Long
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
Long
parentId
)
{
this
.
parentId
=
parentId
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
boolean
hasParent
(){
return
this
.
parentId
!=
null
&&
this
.
parentId
>
0
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreMenu.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
/**
* 系统菜单
*/
public
class
CoreMenu
extends
BaseEntity
{
public
static
final
String
TYPE_SYSTEM
=
"MENU_S"
;
public
static
final
String
TYPE_NAV
=
"MENU_N"
;
public
static
final
String
TYPE_MENUITEM
=
"MENU_M"
;
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
//创建时间
protected
Date
createTime
;
//菜单代码
@NotBlank
(
message
=
"菜单编码不能为空"
,
groups
=
ValidateConfig
.
ADD
.
class
)
private
String
code
;
//功能id
private
Long
functionId
;
//类型 /*1 系统 2 导航 3 菜单项(与功能点有关)*/
@NotNull
(
message
=
"菜单类型不能为空"
)
@Dict
(
type
=
CoreDictType
.
MENU_TYPE
)
private
String
type
;
//菜单名称
@NotBlank
(
message
=
"菜单名称不能为空"
)
private
String
name
;
//上层菜单id
@NotNull
(
message
=
"上层菜单不能为空"
)
private
Long
parentMenuId
;
//排序
@NotNull
(
message
=
"排序不能为空"
)
private
Integer
seq
;
//图标
private
String
icon
;
public
CoreMenu
()
{
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Long
getFunctionId
()
{
return
functionId
;
}
public
void
setFunctionId
(
Long
functionId
)
{
this
.
functionId
=
functionId
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Long
getParentMenuId
()
{
return
parentMenuId
;
}
public
void
setParentMenuId
(
Long
parentMenuId
)
{
this
.
parentMenuId
=
parentMenuId
;
}
public
Integer
getSeq
()
{
return
seq
;
}
public
void
setSeq
(
Integer
seq
)
{
this
.
seq
=
seq
;
}
public
String
getIcon
()
{
return
icon
;
}
public
void
setIcon
(
String
icon
)
{
this
.
icon
=
icon
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreOrg.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
/**
* 机构对象,
* 有母公司,一个系统只有一个母公司,多个集团,集团下可以有多个公司,子公司,部门。如果系统不符合这个设定,需要修改·
*
* <br/>
* 映射了上级机构,可以通过org.parentOrg.xxx取上级机构的属性
*/
public
class
CoreOrg
extends
BaseEntity
{
// 自增id
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
private
Long
id
;
//删除标识
@JsonIgnore
protected
Integer
delFlag
=
0
;
//创建时间
protected
Date
createTime
;
// 机构编号
@NotBlank
(
message
=
"组织编号不能为空"
,
groups
=
ValidateConfig
.
ADD
.
class
)
private
String
code
;
// 机构名称
@NotBlank
(
message
=
"组织名称不能为空"
,
groups
=
{
ValidateConfig
.
ADD
.
class
,
ValidateConfig
.
UPDATE
.
class
})
private
String
name
;
// 上层机构id
private
Long
parentOrgId
;
// 机构类型 1 集团 2 公司,3 部门,4 小组
@Dict
(
type
=
CoreDictType
.
ORG_TYPE
)
@NotBlank
(
message
=
"组织类型不能为空"
,
groups
=
ValidateConfig
.
class
)
private
String
type
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Long
getParentOrgId
()
{
return
parentOrgId
;
}
public
void
setParentOrgId
(
Long
parentOrgId
)
{
this
.
parentOrgId
=
parentOrgId
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getDelFlag
()
{
return
delFlag
;
}
public
void
setDelFlag
(
Integer
delFlag
)
{
this
.
delFlag
=
delFlag
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreRole.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
/**
* 角色
*/
public
class
CoreRole
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
protected
Date
createTime
;
// 角色code
@NotBlank
(
message
=
"角色编码不能为空"
,
groups
=
ValidateConfig
.
ADD
.
class
)
private
String
code
;
// 角色名称
@NotBlank
(
message
=
"角色名称不能为空"
,
groups
=
{
ValidateConfig
.
ADD
.
class
,
ValidateConfig
.
UPDATE
.
class
})
private
String
name
;
// 角色类型,系统的角色,工作流角色
@NotBlank
(
message
=
"角色类型不能为空"
)
@Dict
(
type
=
CoreDictType
.
ROLE_TYPE
)
private
String
type
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
\ No newline at end of file
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreRoleFunction.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
/*
*
* gen by beetlsql 2016-11-22
*/
public
class
CoreRoleFunction
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
// 删除标识
@JsonIgnore
protected
Integer
delFlag
=
0
;
// 创建时间
protected
Date
createTime
;
private
String
dataAccessPolicy
;
// 数据访问类型,1 只看自己的,2 看部门的,3 看公司的 4 自定义,参考policy字段
private
Integer
dataAccessType
;
private
Long
functionId
;
private
Long
roleId
;
public
CoreRoleFunction
()
{
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getDataAccessPolicy
()
{
return
dataAccessPolicy
;
}
public
void
setDataAccessPolicy
(
String
dataAccessPolicy
)
{
this
.
dataAccessPolicy
=
dataAccessPolicy
;
}
public
Integer
getDataAccessType
()
{
return
dataAccessType
;
}
public
void
setDataAccessType
(
Integer
dataAccessType
)
{
this
.
dataAccessType
=
dataAccessType
;
}
public
Long
getFunctionId
()
{
return
functionId
;
}
public
void
setFunctionId
(
Long
functionId
)
{
this
.
functionId
=
functionId
;
}
public
Long
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
public
Integer
getDelFlag
()
{
return
delFlag
;
}
public
void
setDelFlag
(
Integer
delFlag
)
{
this
.
delFlag
=
delFlag
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreRoleMenu.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
/*
*
* gen by beetlsql 2016-11-22
*/
public
class
CoreRoleMenu
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
private
Long
menuId
;
private
Long
roleId
;
private
Date
createTime
;
public
CoreRoleMenu
()
{
}
public
Long
getId
(){
return
id
;
}
public
void
setId
(
Long
id
){
this
.
id
=
id
;
}
public
Long
getMenuId
(){
return
menuId
;
}
public
void
setMenuId
(
Long
menuId
){
this
.
menuId
=
menuId
;
}
public
Long
getRoleId
(){
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
){
this
.
roleId
=
roleId
;
}
public
Date
getCreateTime
(){
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
){
this
.
createTime
=
createTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreUser.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Null
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
/*
* 用户实体
*
*/
public
class
CoreUser
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
protected
Long
id
;
// 删除标识
@JsonIgnore
protected
Integer
delFlag
=
0
;
// 创建时间
protected
Date
createTime
;
// 登录名,编号
@NotBlank
(
message
=
"用户编号不能为空"
,
groups
=
ValidateConfig
.
ADD
.
class
)
@Null
(
message
=
"用户编号不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
private
String
code
;
// 用户姓名
@NotBlank
(
message
=
"用户名不能为空"
)
private
String
name
;
// 组织机构id
private
Long
orgId
;
// 密码
@JsonIgnore
private
String
password
;
@Dict
private
String
state
;
//扩展例子
@Dict
(
type
=
"job_type"
)
private
String
jobType0
;
@Dict
private
String
jobType1
;
private
Date
updateTime
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Long
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
Long
orgId
)
{
this
.
orgId
=
orgId
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Integer
getDelFlag
()
{
return
delFlag
;
}
public
void
setDelFlag
(
Integer
delFlag
)
{
this
.
delFlag
=
delFlag
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getJobType0
()
{
return
jobType0
;
}
public
void
setJobType0
(
String
jobType0
)
{
this
.
jobType0
=
jobType0
;
}
public
String
getJobType1
()
{
return
jobType1
;
}
public
void
setJobType1
(
String
jobType1
)
{
this
.
jobType1
=
jobType1
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreUserRole.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotNull
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
/*
* 用户角色关系
* gen by beetlsql 2016-11-22
*/
public
class
CoreUserRole
extends
BaseEntity
{
// 自增id
@SeqID
(
name
=
"ORACLE_CORE_SEQ_NAME"
)
@AutoID
private
Long
id
;
// 授权机构id
@NotNull
(
message
=
"授权机构不能为空"
)
private
Long
orgId
;
// 授权角色id
@NotNull
(
message
=
"授权角色不能为空"
)
private
Long
roleId
;
// 用户id
@NotNull
(
message
=
"授权用户不能为空"
)
private
Long
userId
;
protected
Date
createTime
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Long
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
Long
orgId
)
{
this
.
orgId
=
orgId
;
}
public
Long
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
public
Long
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Long
userId
)
{
this
.
userId
=
userId
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/AutoGen.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.io.Writer
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
interface
AutoGen
{
public
void
make
(
Target
target
,
Entity
entity
);
public
String
getName
();
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/BaseTarget.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.io.IOException
;
import
org.beetl.core.Configuration
;
import
org.beetl.core.Context
;
import
org.beetl.core.Function
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
public
abstract
class
BaseTarget
implements
Target
{
protected
GroupTemplate
gt
=
null
;
protected
String
urlBase
=
null
;
@Override
public
void
flush
(
AutoGen
gen
,
String
content
)
{
// TODO Auto-generated method stub
}
@Override
public
GroupTemplate
getGroupTemplate
()
{
if
(
gt
!=
null
)
{
return
gt
;
}
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
ClasspathResourceLoader
rs
=
new
ClasspathResourceLoader
(
loader
,
"codeTemplate"
);
try
{
Configuration
cfg
=
Configuration
.
defaultConfiguration
();
cfg
.
setStatementStart
(
"@"
);
cfg
.
setStatementEnd
(
null
);
cfg
.
setHtmlTagSupport
(
false
);
gt
=
new
GroupTemplate
(
rs
,
cfg
);
gt
.
registerFunction
(
"upperFirst"
,
new
Function
()
{
@Override
public
Object
call
(
Object
[]
paras
,
Context
ctx
)
{
String
s
=
(
String
)
paras
[
0
];
return
upperFirst
(
s
);
}
});
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
gt
;
}
public
static
String
upperFirst
(
String
s
)
{
if
(
Character
.
isUpperCase
(
s
.
charAt
(
0
)))
return
s
;
else
return
(
new
StringBuilder
())
.
append
(
Character
.
toUpperCase
(
s
.
charAt
(
0
)))
.
append
(
s
.
substring
(
1
)).
toString
();
}
public
GroupTemplate
getGt
()
{
return
gt
;
}
public
void
setGt
(
GroupTemplate
gt
)
{
this
.
gt
=
gt
;
}
public
String
getUrlBase
()
{
return
urlBase
;
}
public
void
setUrlBase
(
String
urlBase
)
{
this
.
urlBase
=
urlBase
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/ConsoleTarget.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
/**
* 用于代码生成
* @author xiandafu
*
*/
public
class
ConsoleTarget
extends
BaseTarget
{
public
ConsoleTarget
()
{
}
@Override
public
void
flush
(
AutoGen
gen
,
String
content
)
{
System
.
out
.
println
(
"=========="
+
gen
.
getClass
().
getSimpleName
()+
"============="
);
System
.
out
.
println
(
content
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/HtmlGen.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.Template
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
HtmlGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
HtmlIndexGen
indexGen
=
new
HtmlIndexGen
();
indexGen
.
make
(
target
,
entity
);
HtmlEditGen
editGen
=
new
HtmlEditGen
();
editGen
.
make
(
target
,
entity
);
HtmlAddGen
addGen
=
new
HtmlAddGen
();
addGen
.
make
(
target
,
entity
);
}
@Override
public
String
getName
()
{
return
""
;
}
}
class
HtmlIndexGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/html/index.html"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"index.html"
;
}
}
class
HtmlEditGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/html/edit.html"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"edit.html"
;
}
}
class
HtmlAddGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/html/add.html"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"add.html"
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/JSGen.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.Template
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
JSGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
JSDelGen
delGen
=
new
JSDelGen
();
delGen
.
make
(
target
,
entity
);
JSAddGen
addGen
=
new
JSAddGen
();
addGen
.
make
(
target
,
entity
);
JSEditGen
editGen
=
new
JSEditGen
();
editGen
.
make
(
target
,
entity
);
JSApiGen
apiGen
=
new
JSApiGen
();
apiGen
.
make
(
target
,
entity
);
JSIndexGen
indexGen
=
new
JSIndexGen
();
indexGen
.
make
(
target
,
entity
);
}
@Override
public
String
getName
()
{
return
""
;
}
}
class
JSDelGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/js/del.js"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"del.js"
;
}
}
class
JSAddGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/js/add.js"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"add.js"
;
}
}
class
JSApiGen
implements
AutoGen
{
Entity
entity
;
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
this
.
entity
=
entity
;
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/js/entityApi.js"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
entity
.
getCode
()+
"Api.js"
;
}
}
class
JSEditGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/js/edit.js"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"edit.js"
;
}
}
class
JSIndexGen
implements
AutoGen
{
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/js/index.js"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
"index.js"
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/JavaCodeGen.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.Template
;
import
com.ibeetl.admin.core.gen.model.Attribute
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
JavaCodeGen
implements
AutoGen
{
String
basePackage
;
Entity
entity
;
static
String
CR
=
System
.
getProperty
(
"line.separator"
);
public
JavaCodeGen
(
String
basePackage
,
Entity
entity
)
{
this
.
basePackage
=
basePackage
;
this
.
entity
=
entity
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
JavaEntityGen
entityGen
=
new
JavaEntityGen
(
this
);
entityGen
.
make
(
target
,
entity
);
JavaDaoGen
daoGen
=
new
JavaDaoGen
(
this
);
daoGen
.
make
(
target
,
entity
);
JavaServiceGen
serviceGen
=
new
JavaServiceGen
(
this
);
serviceGen
.
make
(
target
,
entity
);
JavaControllerGen
webGen
=
new
JavaControllerGen
(
this
);
webGen
.
make
(
target
,
entity
);
JavaQueryGen
queryGen
=
new
JavaQueryGen
(
this
);
queryGen
.
make
(
target
,
entity
);
}
@Override
public
String
getName
()
{
return
""
;
}
}
class
JavaEntityGen
implements
AutoGen
{
JavaCodeGen
gen
;
public
JavaEntityGen
(
JavaCodeGen
gen
){
this
.
gen
=
gen
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/java/pojo.java"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
template
.
binding
(
"package"
,
gen
.
basePackage
+
".entity"
);
template
.
binding
(
"className"
,
entity
.
getName
());
List
<
Map
<
String
,
Object
>>
attrs
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Attribute
attr:
entity
.
getList
())
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"comment"
,
attr
.
getComment
());
map
.
put
(
"type"
,
attr
.
getJavaType
());
map
.
put
(
"name"
,
attr
.
getName
());
map
.
put
(
"methodName"
,
BaseTarget
.
upperFirst
(
attr
.
getName
()));
map
.
put
(
"isId"
,
attr
.
isId
());
attrs
.
add
(
map
);
}
template
.
binding
(
"attrs"
,
attrs
);
String
srcHead
=
""
;
srcHead
+=
"import java.math.*;"
+
JavaCodeGen
.
CR
;
srcHead
+=
"import java.util.Date;"
+
JavaCodeGen
.
CR
;
srcHead
+=
"import java.sql.Timestamp;"
+
JavaCodeGen
.
CR
;
template
.
binding
(
"imports"
,
srcHead
);
template
.
binding
(
"comment"
,
entity
.
getComment
());
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
gen
.
entity
.
getName
()+
".java"
;
}
}
class
JavaDaoGen
implements
AutoGen
{
JavaCodeGen
gen
;
public
JavaDaoGen
(
JavaCodeGen
gen
){
this
.
gen
=
gen
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/java/dao.java"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
template
.
binding
(
"package"
,
gen
.
basePackage
+
".dao"
);
template
.
binding
(
"basePackage"
,
gen
.
basePackage
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
gen
.
entity
.
getName
()+
"Dao.java"
;
}
}
class
JavaServiceGen
implements
AutoGen
{
JavaCodeGen
gen
;
public
JavaServiceGen
(
JavaCodeGen
gen
){
this
.
gen
=
gen
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/java/service.java"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
template
.
binding
(
"package"
,
gen
.
basePackage
+
".service"
);
template
.
binding
(
"basePackage"
,
gen
.
basePackage
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
gen
.
entity
.
getName
()+
"Service.java"
;
}
}
class
JavaControllerGen
implements
AutoGen
{
JavaCodeGen
gen
;
public
JavaControllerGen
(
JavaCodeGen
gen
){
this
.
gen
=
gen
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/java/controller.java"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
template
.
binding
(
"package"
,
gen
.
basePackage
+
".web"
);
template
.
binding
(
"basePackage"
,
gen
.
basePackage
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
gen
.
entity
.
getName
()+
"Controller.java"
;
}
}
class
JavaQueryGen
implements
AutoGen
{
JavaCodeGen
gen
;
public
JavaQueryGen
(
JavaCodeGen
gen
){
this
.
gen
=
gen
;
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/java/query.java"
);
List
<
Attribute
>
list
=
new
ArrayList
<
Attribute
>();
for
(
Attribute
attr:
entity
.
getList
())
{
if
(
attr
.
isShowInQuery
())
{
list
.
add
(
attr
);
}
}
if
(
list
.
isEmpty
())
{
list
.
add
(
entity
.
getIdAttribute
());
}
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
template
.
binding
(
"package"
,
gen
.
basePackage
+
".web.query"
);
template
.
binding
(
"basePackage"
,
gen
.
basePackage
);
template
.
binding
(
"attrs"
,
list
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
gen
.
entity
.
getName
()+
"Query.java"
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/MavenProjectTarget.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
MavenProjectTarget
extends
BaseTarget
{
Entity
entity
;
String
basePackage
;
String
basePackagePath
=
null
;
public
MavenProjectTarget
(
Entity
entity
,
String
basePackage
)
{
this
.
entity
=
entity
;
this
.
basePackage
=
basePackage
;
this
.
basePackagePath
=
basePackage
.
replace
(
'.'
,
'/'
);
}
@Override
public
void
flush
(
AutoGen
gen
,
String
content
)
{
String
name
=
gen
.
getName
();
String
target
=
null
;
if
(
gen
instanceof
JSDelGen
)
{
target
=
getResourcePath
()+
"/static/js/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
JSEditGen
)
{
target
=
getResourcePath
()+
"/static/js/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
JSAddGen
)
{
target
=
getResourcePath
()+
"/static/js/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
JSApiGen
)
{
target
=
getResourcePath
()+
"/static/js/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
JSIndexGen
)
{
target
=
getResourcePath
()+
"/static/js/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
HtmlIndexGen
)
{
target
=
getResourcePath
()+
"/templates/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
HtmlEditGen
)
{
target
=
getResourcePath
()+
"/templates/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
HtmlAddGen
)
{
target
=
getResourcePath
()+
"/templates/"
+
this
.
urlBase
+
"/"
+
entity
.
getCode
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
MdGen
)
{
target
=
getResourcePath
()+
"/sql/"
+
entity
.
getSystem
()+
"/"
+
name
;
}
else
if
(
gen
instanceof
JavaEntityGen
)
{
target
=
getSrcPath
()+
"/"
+
basePackagePath
+
"/entity/"
+
name
;
}
else
if
(
gen
instanceof
JavaDaoGen
)
{
target
=
getSrcPath
()+
"/"
+
basePackagePath
+
"/dao/"
+
name
;
}
else
if
(
gen
instanceof
JavaQueryGen
)
{
target
=
getSrcPath
()+
"/"
+
basePackagePath
+
"/web/query/"
+
name
;
}
else
if
(
gen
instanceof
JavaServiceGen
)
{
target
=
getSrcPath
()+
"/"
+
basePackagePath
+
"/service/"
+
name
;
}
else
if
(
gen
instanceof
JavaControllerGen
)
{
target
=
getSrcPath
()+
"/"
+
basePackagePath
+
"/web/"
+
name
;
}
if
(
target
==
null
)
{
return
;
}
flush
(
target
,
content
);
}
protected
void
flush
(
String
path
,
String
content
)
{
FileWriter
fw
;
try
{
File
file
=
new
File
(
path
);
if
(!
file
.
getParentFile
().
exists
())
{
file
.
getParentFile
().
mkdirs
();
}
fw
=
new
FileWriter
(
new
File
(
path
));
fw
.
write
(
content
);
fw
.
close
();
System
.
out
.
println
(
path
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
private
static
String
getSrcPath
()
{
return
getRootPath
()
+
File
.
separator
+
"src/main/java"
;
}
private
static
String
getResourcePath
()
{
return
getRootPath
()
+
File
.
separator
+
"src/main/resources"
;
}
private
static
String
getRootPath
()
{
String
srcPath
;
String
userDir
=
System
.
getProperty
(
"user.dir"
);
if
(
userDir
==
null
)
{
throw
new
NullPointerException
(
"用户目录未找到"
);
}
return
userDir
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/MdGen.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.Template
;
import
com.ibeetl.admin.core.gen.model.Attribute
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
MdGen
implements
AutoGen
{
static
String
CR
=
System
.
getProperty
(
"line.separator"
);
Entity
entity
=
null
;
public
MdGen
()
{
}
@Override
public
void
make
(
Target
target
,
Entity
entity
)
{
this
.
entity
=
entity
;
GroupTemplate
gt
=
target
.
getGroupTemplate
();
Template
template
=
gt
.
getTemplate
(
"/md/entity.md"
);
template
.
binding
(
"entity"
,
entity
);
template
.
binding
(
"target"
,
target
);
String
content
=
template
.
render
();
target
.
flush
(
this
,
content
);
}
@Override
public
String
getName
()
{
return
entity
.
getCode
()+
".md"
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/Target.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
org.beetl.core.GroupTemplate
;
/**
* 描述如何输出代码,有打印后台,页面输出,或者直接生成到项目里
* @author lijiazhi
*
*/
public
interface
Target
{
public
void
flush
(
AutoGen
gen
,
String
content
);
public
GroupTemplate
getGroupTemplate
();
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/WebTarget.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.ibeetl.admin.core.gen.model.Entity
;
public
class
WebTarget
extends
MavenProjectTarget
{
public
Map
<
Object
,
String
>
map
=
new
HashMap
<
Object
,
String
>();
public
WebTarget
(
Entity
entity
,
String
basePackage
)
{
super
(
entity
,
basePackage
);
}
@Override
public
void
flush
(
AutoGen
gen
,
String
content
)
{
map
.
put
(
gen
,
content
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/model/Attribute.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen.model
;
public
class
Attribute
{
private
String
name
;
private
String
colName
;
private
String
javaType
;
private
String
displayName
;
private
boolean
isId
;
private
boolean
showInQuery
=
false
;
private
String
comment
;
public
Attribute
()
{
super
();
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getColName
()
{
return
colName
;
}
public
void
setColName
(
String
colName
)
{
this
.
colName
=
colName
;
}
public
String
getJavaType
()
{
return
javaType
;
}
public
void
setJavaType
(
String
javaType
)
{
this
.
javaType
=
javaType
;
}
public
String
getDisplayName
()
{
if
(
displayName
==
null
)
{
return
this
.
name
;
}
return
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
public
boolean
isId
()
{
return
isId
;
}
public
void
setId
(
boolean
isId
)
{
this
.
isId
=
isId
;
}
public
boolean
isShowInQuery
()
{
return
showInQuery
;
}
public
void
setShowInQuery
(
boolean
showInQuery
)
{
this
.
showInQuery
=
showInQuery
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/gen/model/Entity.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.gen.model
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Entity
{
String
name
;
String
tableName
;
String
code
;
String
displayName
;
ArrayList
<
Attribute
>
list
=
new
ArrayList
<
Attribute
>();
Attribute
[]
temp
=
null
;
Attribute
idAttribute
;
Attribute
nameAttribute
;
String
comment
;
String
system
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getTableName
()
{
return
tableName
;
}
public
void
setTableName
(
String
tableName
)
{
this
.
tableName
=
tableName
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getDisplayName
()
{
if
(
displayName
==
null
)
{
return
this
.
displayName
;
}
return
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
public
ArrayList
<
Attribute
>
getList
()
{
return
list
;
}
public
void
setList
(
ArrayList
<
Attribute
>
list
)
{
this
.
list
=
list
;
}
public
Attribute
getIdAttribute
()
{
return
idAttribute
;
}
public
void
setIdAttribute
(
Attribute
idAttribute
)
{
this
.
idAttribute
=
idAttribute
;
}
public
Attribute
getNameAttribute
()
{
return
nameAttribute
;
}
public
void
setNameAttribute
(
Attribute
nameAttribute
)
{
this
.
nameAttribute
=
nameAttribute
;
}
public
String
getSystem
()
{
return
system
;
}
public
void
setSystem
(
String
system
)
{
this
.
system
=
system
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
Attribute
[]
getTemp
()
{
return
temp
;
}
public
void
setTemp
(
Attribute
[]
temp
)
{
this
.
temp
=
temp
;
}
public
List
<
Attribute
>
getGeneralList
(){
List
<
Attribute
>
newList
=
new
ArrayList
<
Attribute
>();
for
(
Attribute
attr:
list
)
{
if
(
attr
.
getName
().
equals
(
this
.
idAttribute
.
getName
()))
{
continue
;
}
newList
.
add
(
attr
);
}
return
newList
;
}
}
Prev
1
…
6
7
8
9
10
11
12
13
14
…
23
Next
Write
Preview
Supports
Markdown
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