Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pension
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mengmeng
pension
Commits
92513729
Commit
92513729
authored
May 18, 2021
by
Shen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 添加FieldMetaObjectHandler类,自动填充create_date字段
parent
c3f9539c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
17 deletions
+72
-17
PensionOrderServiceImpl.java
...es/serviceOrder/service/impl/PensionOrderServiceImpl.java
+17
-15
FieldMetaObjectHandler.java
...src/main/java/io/hmit/handler/FieldMetaObjectHandler.java
+34
-0
PensionOrderEntity.java
.../hmit/modules/serviceOrder/entity/PensionOrderEntity.java
+19
-0
PensionOrderServiceImpl.java
...es/serviceOrder/service/impl/PensionOrderServiceImpl.java
+2
-2
No files found.
hmit-admin/src/main/java/io/hmit/modules/serviceOrder/service/impl/PensionOrderServiceImpl.java
View file @
92513729
...
...
@@ -6,6 +6,7 @@ import io.hmit.common.constant.Constant;
import
io.hmit.common.page.PageData
;
import
io.hmit.common.service.impl.CrudServiceImpl
;
import
io.hmit.common.utils.ConvertUtils
;
import
io.hmit.common.utils.SubListForPageUtil
;
import
io.hmit.modules.serviceOrder.dao.PensionOrderDao
;
import
io.hmit.modules.serviceOrder.dto.PensionOrderDTO
;
import
io.hmit.modules.serviceOrder.entity.PensionOrderEntity
;
...
...
@@ -17,10 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* 订单表
...
...
@@ -74,17 +73,20 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
result
.
addAll
(
list
);
}
// page.setTotal(result.size());
Integer
pageNum
=
Integer
.
parseInt
(
params
.
get
(
"page"
).
toString
());
Integer
pageSize
=
Integer
.
parseInt
(
params
.
get
(
"limit"
).
toString
());
Integer
count
=
result
.
size
();
Integer
pageNo
=
(
pageNum
-
1
)
*
pageSize
;
List
<
PensionOrderDTO
>
list2
;
if
(
pageNo
+
pageSize
>
count
)
{
list2
=
result
.
subList
(
pageNo
,
count
);
}
else
{
list2
=
result
.
subList
(
pageNo
,
pageNo
+
pageSize
);
}
return
getPageData
(
list2
,
result
.
size
(),
PensionOrderDTO
.
class
);
// Integer pageNum = Integer.parseInt(params.get("page").toString());
// Integer pageSize = Integer.parseInt(params.get("limit").toString());
// Integer count = result.size();
// Integer pageNo = (pageNum - 1) * pageSize;
// List<PensionOrderDTO> list2 ;
// if (pageNo+pageSize > count) {
// list2 = result.subList(pageNo,count );
// }else {
// list2 = result.subList(pageNo,pageNo+pageSize);
// }
// return getPageData(list2, result.size(), PensionOrderDTO.class);
List
<
PensionOrderDTO
>
sortList
=
result
.
stream
().
sorted
(
Comparator
.
comparing
(
PensionOrderDTO:
:
getCreateDate
)).
collect
(
Collectors
.
toList
());
Collections
.
reverse
(
sortList
);
return
getPageData
(
SubListForPageUtil
.
getSubList
(
params
,
sortList
),
sortList
.
size
(),
PensionOrderDTO
.
class
);
}
@Override
...
...
hmit-api/src/main/java/io/hmit/handler/FieldMetaObjectHandler.java
0 → 100644
View file @
92513729
package
io
.
hmit
.
handler
;
import
com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* 公共字段,自动填充值
*
* @author zsh 408538940@qq.com
*/
@Component
public
class
FieldMetaObjectHandler
implements
MetaObjectHandler
{
private
final
static
String
CREATE_DATE
=
"createDate"
;
private
final
static
String
UPDATE_DATE
=
"updateDate"
;
@Override
public
void
insertFill
(
MetaObject
metaObject
)
{
Date
date
=
new
Date
();
//创建时间
setInsertFieldValByName
(
CREATE_DATE
,
date
,
metaObject
);
//更新时间
setInsertFieldValByName
(
UPDATE_DATE
,
date
,
metaObject
);
}
@Override
public
void
updateFill
(
MetaObject
metaObject
)
{
//更新时间
setUpdateFieldValByName
(
UPDATE_DATE
,
new
Date
(),
metaObject
);
}
}
\ No newline at end of file
hmit-api/src/main/java/io/hmit/modules/serviceOrder/entity/PensionOrderEntity.java
View file @
92513729
package
io
.
hmit
.
modules
.
serviceOrder
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
io.hmit.common.entity.BaseEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -19,6 +23,11 @@ import java.util.Date;
public
class
PensionOrderEntity
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* id
*/
@TableId
private
Long
id
;
/**
* 订单编号
*/
...
...
@@ -120,5 +129,15 @@ public class PensionOrderEntity extends BaseEntity {
* 所属社区Id
*/
private
Long
communityId
;
/**
* 创建者
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Long
creator
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createDate
;
}
hmit-api/src/main/java/io/hmit/modules/serviceOrder/service/impl/PensionOrderServiceImpl.java
View file @
92513729
...
...
@@ -135,7 +135,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
list
.
addAll
(
list2
);
}
// page.setTotal(list.size());
List
<
PensionOrderDTO
>
sortList
=
list
.
stream
().
sorted
(
Comparator
.
comparing
(
PensionOrderDTO:
:
get
Id
)).
collect
(
Collectors
.
toList
());
List
<
PensionOrderDTO
>
sortList
=
list
.
stream
().
sorted
(
Comparator
.
comparing
(
PensionOrderDTO:
:
get
CreateDate
)).
collect
(
Collectors
.
toList
());
Collections
.
reverse
(
sortList
);
return
getPageData
(
getSubList
(
params
,
sortList
),
sortList
.
size
(),
PensionOrderDTO
.
class
);
}
...
...
@@ -169,7 +169,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
result
.
addAll
(
list
);
}
// page.setTotal(result.size());
List
<
PensionOrderDTO
>
sortList
=
result
.
stream
().
sorted
(
Comparator
.
comparing
(
PensionOrderDTO:
:
get
Id
)).
collect
(
Collectors
.
toList
());
List
<
PensionOrderDTO
>
sortList
=
result
.
stream
().
sorted
(
Comparator
.
comparing
(
PensionOrderDTO:
:
get
CreateDate
)).
collect
(
Collectors
.
toList
());
Collections
.
reverse
(
sortList
);
return
getPageData
(
getSubList
(
params
,
sortList
),
sortList
.
size
(),
PensionOrderDTO
.
class
);
}
...
...
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