Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
25c1f1f0
提交
25c1f1f0
编写于
12月 26, 2021
作者:
ibiz4j
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mapper
上级
a778de0b
变更
5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
181 行增加
和
6 行删除
+181
-6
EntityModel.java
...e/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
+33
-0
{{entities@SQL}}Mapper.java.hbs
...Name}}/{{modules}}/mapper/{{entities@SQL}}Mapper.java.hbs
+98
-0
I{{entities@SQL}}Service.java.hbs
...e}}/{{modules}}/service/I{{entities@SQL}}Service.java.hbs
+1
-1
{{entities@SQL}}ServiceImpl.java.hbs
...dules}}/service/impl/{{entities@SQL}}ServiceImpl.java.hbs
+28
-5
{{entities@SQL}}Mapper.xml.hbs
...r/{{modules}}/{{entities}}/{{entities@SQL}}Mapper.xml.hbs
+21
-0
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
浏览文件 @
25c1f1f0
...
...
@@ -14,6 +14,7 @@ import net.ibizsys.model.dataentity.defield.IPSDEField;
import
net.ibizsys.model.dataentity.defield.IPSLinkDEField
;
import
net.ibizsys.model.dataentity.der.IPSDER1N
;
import
net.ibizsys.model.dataentity.der.IPSDERBase
;
import
net.ibizsys.model.dataentity.der.IPSDERInherit
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam
;
import
net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl
;
import
org.springframework.util.Assert
;
...
...
@@ -111,6 +112,10 @@ public class EntityModel extends BaseModel {
return
this
;
}
public
boolean
isHasReferences
()
{
return
!
ObjectUtils
.
isEmpty
(
references
);
}
private
Map
<
String
,
RelationshipModel
>
refMaps
;
...
...
@@ -363,6 +368,34 @@ public class EntityModel extends BaseModel {
}
public
boolean
isIndexSubDE
()
{
if
(
this
.
getDataEntity
().
getMinorPSDERs
()==
null
)
return
false
;
for
(
IPSDERBase
MinorPSDER:
this
.
getDataEntity
().
getMinorPSDERs
())
{
if
(
"DERINHERIT"
.
equals
(
MinorPSDER
.
getDERType
())||
"DERINDEX"
.
equals
(
MinorPSDER
.
getDERType
())&&
MinorPSDER
.
getMajorPSDataEntity
().
getVirtualMode
()!=
3
&&
MinorPSDER
.
getMajorPSDataEntity
().
getIndexTypePSDEField
()!=
null
)
{
return
true
;
}
}
return
false
;
}
public
boolean
isLogicInherit
()
{
if
(
this
.
getDataEntity
().
getMinorPSDERs
()==
null
)
return
false
;
for
(
IPSDERBase
MinorPSDER:
this
.
getDataEntity
().
getMinorPSDERs
())
{
if
(
"DERINHERIT"
.
equals
(
MinorPSDER
.
getDERType
())
&&
MinorPSDER
instanceof
IPSDERInherit
)
{
return
((
IPSDERInherit
)
MinorPSDER
).
isLogicInherit
();
}
}
return
false
;
}
private
Map
<
String
,
POSchema
>
poSchemas
;
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/mapper/{{entities@SQL}}Mapper.java.hbs
0 → 100644
浏览文件 @
25c1f1f0
package
{{
packageName
}}
.
{{
module
}}
.mapper;
import java.util.List;
import org.apache.ibatis.annotations.*;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import java.util.Map;
import org.apache.ibatis.annotations.Select;
import
{{
packageName
}}
.
{{
module
}}
.domain.
{{
entity
.
codeName
}}
;
import
{{
packageName
}}
.
{{
module
}}
.filter.
{{
entity
.
codeName
}}
SearchContext;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import om.baomidou.dynamic.datasource.annotation.DS;
import com.alibaba.fastjson.JSONObject;
{{#
dsName
}}
@DS("
{{
entity
.
dataSource
}}
")
{{/
dsName
}}
public interface
{{
entity
.
codeName
}}
Mapper extends BaseMapper
<
{{
entity
.
codeName
}}
>
{
{{#
entity
.
dataSets
}}
Page
<
{{
entity
.
codeName
}}
>
search
{{
codeName
}}
(IPage page, @Param("srf")
{{
entity
.
codeName
}}
SearchContext context, @Param("ew") Wrapper
<
{{
entity
.
codeName
}}
>
wrapper);
List
<
{{
entity
.
codeName
}}
>
list
{{
codeName
}}
(@Param("srf")
{{
entity
.
codeName
}}
SearchContext context, @Param("ew") Wrapper
<
{{
entity
.
codeName
}}
>
wrapper);
{{/
entity
.
dataSets
}}
@Override
{{#
enableEntityCache
}}
@Cacheable(value = "
{{
entity
.
codeName
.
lowerCase
}}
", key = "'row:'+#p0")
{{/
enableEntityCache
}}
{{
entity
.
codeName
}}
selectById(Serializable id);
@Override
{{#
enableEntityCache
}}
@CacheEvict(value = "
{{
entity
.
codeName
.
lowerCase
}}
", key = "'row:'+#p0.
{{
entity
.
keyField
.
codeName
.
camelCase
}}
")
{{/
enableEntityCache
}}
int insert(
{{
entity
.
codeName
}}
entity);
@Override
{{#
enableEntityCache
}}
@CacheEvict(value = "
{{
entity
.
codeName
.
lowerCase
}}
", key = "'row:'+#p0.
{{
entity
.
keyField
.
codeName
.
camelCase
}}
")
{{/
enableEntityCache
}}
int updateById(@Param(Constants.ENTITY)
{{
entity
.
codeName
}}
entity);
@Override
{{#
enableEntityCache
}}
@CacheEvict(value = "
{{
entity
.
codeName
.
lowerCase
}}
", key = "'row:'+#p0.
{{
entity
.
keyField
.
codeName
.
camelCase
}}
", condition ="#p0 != null")
{{/
enableEntityCache
}}
int update(@Param(Constants.ENTITY)
{{
entity
.
codeName
}}
entity, @Param("ew") Wrapper
<
{{
entity
.
codeName
}}
>
updateWrapper);
@Override
{{#
enableEntityCache
}}
@CacheEvict(value = "
{{
entity
.
codeName
.
lowerCase
}}
", key = "'row:'+#p0")
{{/
enableEntityCache
}}
int deleteById(Serializable id);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select("${sql}")
List
<JSONObject>
selectBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义更新SQL
* @param sql
* @return
*/
@Update("${sql}")
boolean updateBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义插入SQL
* @param sql
* @return
*/
@Insert("${sql}")
boolean insertBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义删除SQL
* @param sql
* @return
*/
@Delete("${sql}")
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
{{#
entity
.
references
}}
List
<
{{
entity
.
codeName
}}
>
selectBy
{{
fkField
.
codeName
.
pascalCase
}}
(@Param("
{{
fkField
.
name
.
lowerCase
}}
") Serializable
{{
fkField
.
codeName
.
camelCase
}}
);
{{/
entity
.
references
}}
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/service/I{{entities@SQL}}Service.java.hbs
浏览文件 @
25c1f1f0
...
...
@@ -16,7 +16,7 @@ import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import com.baomidou.mybatisplus.extension.service.IService;
impo
t
t om.baomidou.dynamic.datasource.annotation.DS;
impo
r
t om.baomidou.dynamic.datasource.annotation.DS;
import
{{
packageName
}}
.
{{
entity
.
module
}}
.domain.
{{
entity
.
codeName
}}
;
import
{{
packageName
}}
.
{{
entity
.
module
}}
.filter.
{{
entity
.
codeName
}}
SearchContext;
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/service/impl/{{entities@SQL}}ServiceImpl.java.hbs
浏览文件 @
25c1f1f0
...
...
@@ -73,14 +73,37 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
boolean checkKey(
{{
entity
.
codeName
}}
et);
@Override
{{#
eq
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
{{#
eq
entity
.
actions
.
create
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
create
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean create(
{{
entity
.
codeName
}}
et) {
{{#
entity
.
hasReferences
}}
fillParentData(et);
{{/
entity
.
hasReferences
}}
{{#
entity
.
isIndexSubDE
}}
createIndexMajorEntityData(et);
{{/
entity
.
isIndexSubDE
}}
{{#if
entity
.
isLogicInheritDE
}}
if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("
{{
entity
.
keyfield
.
name
.
lowerCase
}",
et
.
get
{{
keyfield
.
codeName
.
pascalCase
}}
())))
return false;
{{/
else
}}
if(!this.retBool(this.baseMapper.insert(et)))
return false;
{{/if}}
{{#
each
entity
.
nesteds
}}
{{#
unless
listCode
}}
{{#
unless
columnName
}}
{{
camelCase
entityCodeName
}}
service.saveBy
{{
codeName
.
pascalCase
}}
;
{{/
unless
}}
{{/
unless
}}
{{/
each
}}
{{#
entity
.
hasReferences
}}
${srfr7templcaseformat(MinorEntity.getCodeName())}Service.saveBy${srfr7templcaseformat(MajorDerField.codeName)?cap_first}(et.get${srfr7templcaseformat(keyfield.codeName)?cap_first}(), et.get${srfr7templcaseformat(listcode)?cap_first}());
{{/
entity
.
hasReferences
}}
}
{{#
eq
entity
.
actions
.
create
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
create
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean createBatch(List
<
{{
entity
.
codeName
}}
>
list) {
}
{{#
enableEntityCache
}}
@CacheEvict(value = "
{{
entity
.
codeName
.
lowerCase
}}
", allEntries = true)
{{/
enableEntityCache
}}
boolean createBatch(List
<
{{
entity
.
codeName
}}
>
list);
boolean update(
{{
entity
.
codeName
}}
et);
{{#
enableEntityCache
}}
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/resources/mapper/{{modules}}/{{entities}}/{{entities@SQL}}Mapper.xml.hbs
0 → 100644
浏览文件 @
25c1f1f0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"
{{
packageName
}}
.
{{
module
}}
.mapper.
{{
entity
.
codeName
}}
Mapper"
>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap
id=
"${de.codeName}ResultMap"
type=
"${pub.getPKGCodeName()}.core.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName}"
autoMapping=
"true"
>
<
#
if
de
.
getKeyPSDEField
().
isPhisicalDEField
()==
true
>
<id
property=
"${srfr7templcaseformat(de.getKeyPSDEField().codeName)}"
column=
"${de.getKeyPSDEField().getName()?lower_case}"
/>
<!--主键字段映射-->
</
#
if>
<
#
comment
>
外键值字段映射:由于需要将一个数据库列注入到2个domian属性中(主关系实体对象),由于已经手动将列映射给主关系对象,所以autoMapping将不会自动注入外键id,需要再次声明映射关系
</
#
comment>
<
#
comment
>
属性名称与代码名称不一致时,强制进行映射
</
#
comment>
<
#
list
item
.
getPSDEFields
()
as
defield
>
<
#
if
defield
.
isKeyDEField
()!=
true
&&
((
defield
.
getDataType
())!"")!='
ONE2MANYDATA
'
>
<
#
if
srfr7templcaseformat
(
defield
.
codeName
)?
lower_case
!=
defield
.
name
?
lower_case
||
defield
.
getDataType
()=='
PICKUP
'
>
<result
property=
"${srfr7templcaseformat(defield.codeName)}"
column=
"${defield.getName()?lower_case}"
/>
</
#
if>
</
#
if>
</
#
list>
</resultMap>
</mapper>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录