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
Eladmin
Commits
8cb7dc88
"src/vscode:/vscode.git/clone" did not exist on "dd4f77889cdefe5de6beb7c89599e68f710f785c"
Commit
8cb7dc88
authored
Oct 24, 2019
by
dqjdda
Browse files
加入实体基类、DTO基类、修改部分实体继承基类
parent
bf7c1eeb
Changes
46
Show whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java
View file @
8cb7dc88
package
me.zhengjie.modules.system.service.mapper
;
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.mapper.EntityMapper
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.ReportingPolicy
;
import
java.util.List
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-11-23
* @date 2018-11-23
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
RoleMapper
.
class
,
DeptMapper
.
class
,
JobMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
RoleMapper
.
class
,
DeptMapper
.
class
,
JobMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
UserMapper
extends
Entity
Mapper
<
UserDTO
,
User
>
{
public
interface
UserMapper
extends
Base
Mapper
<
UserDTO
,
User
>
{
@Mapping
(
source
=
"user.userAvatar.realName"
,
target
=
"avatar"
)
@Mapping
(
source
=
"user.userAvatar.realName"
,
target
=
"avatar"
)
UserDTO
toDto
(
User
user
);
UserDTO
toDto
(
User
user
);
...
...
eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl
View file @
8cb7dc88
package
$
{
package
}
.service.mapper;
package
$
{
package
}
.service.mapper;
import
me.zhengjie.
mapper.Entity
Mapper;
import
me.zhengjie.
base.Base
Mapper;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
org.mapstruct.Mapper;
import
org.mapstruct.Mapper;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
*
@date $
{
date
}
*
@date $
{
date
}
*/
*/
@
Mapper
(
componentModel
=
"spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
@
Mapper
(
componentModel
=
"spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public
interface $
{
className
}
Mapper extends
Entity
Mapper<$
{
className
}
DTO, $
{
className
}
>
{
public
interface $
{
className
}
Mapper extends
Base
Mapper<$
{
className
}
DTO, $
{
className
}
>
{
}
}
\ No newline at end of file
eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java
View file @
8cb7dc88
package
me.zhengjie.domain
;
package
me.zhengjie.domain
;
import
lombok.AllArgsConstructor
;
import
lombok.*
;
import
lombok.Data
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
cn.hutool.core.bean.copier.CopyOptions
;
import
lombok.NoArgsConstructor
;
import
me.zhengjie.base.BaseEntity
;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.UpdateTimestamp
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.sql.Timestamp
;
import
java.io.Serializable
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@Getter
@Setter
@Entity
@Entity
@Data
@Table
(
name
=
"local_storage"
)
@Table
(
name
=
"local_storage"
)
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
public
class
LocalStorage
implem
en
t
s
Serializable
{
public
class
LocalStorage
ext
en
d
s
BaseEntity
{
// ID
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
)
@Column
(
name
=
"id"
)
...
@@ -57,16 +50,6 @@ public class LocalStorage implements Serializable {
...
@@ -57,16 +50,6 @@ public class LocalStorage implements Serializable {
@Column
(
name
=
"operate"
)
@Column
(
name
=
"operate"
)
private
String
operate
;
private
String
operate
;
// 创建日期
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
// 修改日期
@Column
(
name
=
"update_time"
)
@UpdateTimestamp
private
Timestamp
updateTime
;
public
LocalStorage
(
String
realName
,
String
name
,
String
suffix
,
String
path
,
String
type
,
String
size
,
String
operate
)
{
public
LocalStorage
(
String
realName
,
String
name
,
String
suffix
,
String
path
,
String
type
,
String
size
,
String
operate
)
{
this
.
realName
=
realName
;
this
.
realName
=
realName
;
this
.
name
=
name
;
this
.
name
=
name
;
...
...
eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageDTO.java
View file @
8cb7dc88
package
me.zhengjie.service.dto
;
package
me.zhengjie.service.dto
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Getter
;
import
lombok.Data
;
import
lombok.Setter
;
import
java.sql.Timestamp
;
import
me.zhengjie.base.BaseDTO
;
import
java.io.Serializable
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@Data
@Getter
public
class
LocalStorageDTO
implements
Serializable
{
@Setter
public
class
LocalStorageDTO
extends
BaseDTO
{
// ID
// ID
private
Long
id
;
private
Long
id
;
...
@@ -32,10 +31,4 @@ public class LocalStorageDTO implements Serializable {
...
@@ -32,10 +31,4 @@ public class LocalStorageDTO implements Serializable {
// 操作人
// 操作人
private
String
operate
;
private
String
operate
;
// 创建日期
private
Timestamp
createTime
;
// 修改日期
private
Timestamp
updateTime
;
}
}
\ No newline at end of file
eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java
View file @
8cb7dc88
...
@@ -56,7 +56,7 @@ public class PictureServiceImpl implements PictureService {
...
@@ -56,7 +56,7 @@ public class PictureServiceImpl implements PictureService {
public
Picture
upload
(
MultipartFile
multipartFile
,
String
username
)
{
public
Picture
upload
(
MultipartFile
multipartFile
,
String
username
)
{
File
file
=
FileUtil
.
toFile
(
multipartFile
);
File
file
=
FileUtil
.
toFile
(
multipartFile
);
// 验证是否重复上传
// 验证是否重复上传
Picture
picture
=
pictureRepository
.
findByMd5Code
(
FileUtil
.
getM
D
5
(
file
));
Picture
picture
=
pictureRepository
.
findByMd5Code
(
FileUtil
.
getM
d
5
(
file
));
if
(
picture
!=
null
){
if
(
picture
!=
null
){
return
picture
;
return
picture
;
}
}
...
@@ -70,7 +70,7 @@ public class PictureServiceImpl implements PictureService {
...
@@ -70,7 +70,7 @@ public class PictureServiceImpl implements PictureService {
picture
=
JSON
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
(),
Picture
.
class
);
picture
=
JSON
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
(),
Picture
.
class
);
picture
.
setSize
(
FileUtil
.
getSize
(
Integer
.
parseInt
(
picture
.
getSize
())));
picture
.
setSize
(
FileUtil
.
getSize
(
Integer
.
parseInt
(
picture
.
getSize
())));
picture
.
setUsername
(
username
);
picture
.
setUsername
(
username
);
picture
.
setMd5Code
(
FileUtil
.
getM
D
5
(
file
));
picture
.
setMd5Code
(
FileUtil
.
getM
d
5
(
file
));
picture
.
setFilename
(
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())+
"."
+
FileUtil
.
getExtensionName
(
multipartFile
.
getOriginalFilename
()));
picture
.
setFilename
(
FileUtil
.
getFileNameNoEx
(
multipartFile
.
getOriginalFilename
())+
"."
+
FileUtil
.
getExtensionName
(
multipartFile
.
getOriginalFilename
()));
pictureRepository
.
save
(
picture
);
pictureRepository
.
save
(
picture
);
//删除临时文件
//删除临时文件
...
@@ -97,7 +97,6 @@ public class PictureServiceImpl implements PictureService {
...
@@ -97,7 +97,6 @@ public class PictureServiceImpl implements PictureService {
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
pictureRepository
.
delete
(
picture
);
pictureRepository
.
delete
(
picture
);
}
}
}
}
@Override
@Override
...
...
eladmin-tools/src/main/java/me/zhengjie/service/mapper/LocalStorageMapper.java
View file @
8cb7dc88
package
me.zhengjie.service.mapper
;
package
me.zhengjie.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.domain.LocalStorage
;
import
me.zhengjie.service.dto.LocalStorageDTO
;
import
me.zhengjie.service.dto.LocalStorageDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapper
;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
...
@@ -11,6 +11,6 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-09-05
* @date 2019-09-05
*/
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
LocalStorageMapper
extends
Entity
Mapper
<
LocalStorageDTO
,
LocalStorage
>
{
public
interface
LocalStorageMapper
extends
Base
Mapper
<
LocalStorageDTO
,
LocalStorage
>
{
}
}
\ No newline at end of file
Prev
1
2
3
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