Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
26274cdf
Commit
26274cdf
authored
Mar 14, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改扫描bug
parent
b66d539b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
149 deletions
+26
-149
BeanDtoVoUtils.java
...oin/amos/boot/module/common/biz/utils/BeanDtoVoUtils.java
+0
-134
CommonResponseUtil.java
...amos/boot/module/common/biz/utils/CommonResponseUtil.java
+26
-15
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/utils/BeanDtoVoUtils.java
View file @
26274cdf
//package com.yeejoin.amos.boot.module.common.biz.utils;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.yeejoin.amos.boot.module.common.api.dto.FireExpertsDto;
//import com.yeejoin.amos.boot.module.common.api.entity.FireExperts;
//import org.springframework.beans.BeanUtils;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDate;
//import java.util.Calendar;
//import java.util.Date;
//
///**
// * @title: 实体类 Dto,Vo,entity 转换工具类
// * @Author fpy
// * @Date: 2021/6/3 13:53
// */
//@Component
//public class BeanDtoVoUtils {
//
// /**
// * Dot ,Vo ,Entity 相互转换
// *
// * @param source 原数据
// * @param targetClass 目标类
// * @param <T> 泛型类
// * @return 转换返回值
// */
// public static <T> T convert(Object source, Class<T> targetClass) {
// // 判断source是否为空
// if (source == null) {
// return null;
// }
// // 判断targetClass是否为空
// if (targetClass == null) {
// return null;
// }
// try {
// // 创建新的对象实例
// T target = targetClass.newInstance();
// // 把原对象数据拷贝到新对象
// BeanUtils.copyProperties(source, target);
// // 返回新对象
// return target;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * Dot ,Vo ,Entity 相互转换
// *
// * @param source 原数据
// * @return 转换返回值
// */
// public static FireExpertsDto convertFireExperts(FireExperts source) {
// // 判断source是否为空
// if (source == null) {
// return null;
// }
// try {
// // 创建新的对象实例
// FireExpertsDto target = FireExpertsDto.class.newInstance();
// // 把原对象数据拷贝到新对象
// BeanUtils.copyProperties(source, target);
// // 计算年龄
// int age = getAge(source.getBirthdayTime());
// target.setAge(age);
// // 返回新对象
// return target;
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// /**
// * IPage<Entity> 分页对象转 Page<Dto>
// *
// * @param page 原分页对象
// * @param v 目标vo类
// * @param <E> 泛型类
// * @param <V> 泛型类
// * @return 转换后的分页对象
// */
// public static <E, V> IPage<V> iPageDtoStream(IPage<E> page, Class<V> v) {
// return page.convert(item -> {
// try {
// return convert(item, v);
// } catch (Exception e) {
// return null;
// }
// });
// }
//
// /**
// * IPage<Entity> 分页对象转 Page<Dto>
// *
// * @param page 原分页对象
// * @return 转换后的分页对象
// */
// public static IPage<FireExpertsDto> iPageDtoStreamFireExperts(IPage<FireExperts> page) {
// return page.convert(item -> {
// try {
// return convertFireExperts(item);
// } catch (Exception e) {
// return null;
// }
// });
// }
//
// //由出生日期获得年龄
// public static int getAge(Date birthDay) {
// if (birthDay == null) {
// return 0;
// }
// LocalDate now = LocalDate.now();
// Calendar cal = Calendar.getInstance();
// cal.setTime(birthDay);
// int yearBirth = cal.get(Calendar.YEAR);
// int monthBirth = cal.get(Calendar.MONTH) + 1;
// int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
//
// LocalDate birth = LocalDate.of(yearBirth, monthBirth, dayOfMonthBirth);
// if (birth.isAfter(now)) {
// return 0;
// }
// int age = birth.until(now).getYears();
// return age;
// }
//
//}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/utils/CommonResponseUtil.java
View file @
26274cdf
...
...
@@ -5,55 +5,66 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
public
class
CommonResponseUtil
{
public
static
ResponseModel
success
()
private
static
final
String
FAILURE
=
"FAILURE"
;
public
static
ResponseModel
<
Object
>
success
()
{
ResponseModel
res
=
new
ResponseModel
();
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setDevMessage
(
"SUCCESS"
);
res
.
setStatus
(
HttpStatus
.
OK
.
value
());
return
res
;
}
public
static
ResponseModel
success
(
Object
obj
)
public
static
ResponseModel
<
Object
>
success
(
Object
obj
)
{
ResponseModel
res
=
new
ResponseModel
();
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setResult
(
obj
);
res
.
setDevMessage
(
"SUCCESS"
);
res
.
setStatus
(
HttpStatus
.
OK
.
value
());
return
res
;
}
public
static
ResponseModel
success
(
Object
obj
,
String
message
)
public
static
ResponseModel
<
Object
>
success
(
Object
obj
,
String
message
)
{
ResponseModel
res
=
new
ResponseModel
();
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setResult
(
obj
);
res
.
setDevMessage
(
message
);
res
.
setStatus
(
HttpStatus
.
OK
.
value
());
return
res
;
}
public
static
ResponseModel
failure
()
public
static
ResponseModel
<
Object
>
failure
()
{
ResponseModel
res
=
new
ResponseModel
();
res
.
setDevMessage
(
"FAILURE"
);
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setDevMessage
(
FAILURE
);
res
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
return
res
;
}
public
static
ResponseModel
failure
(
String
message
)
public
static
ResponseModel
<
Object
>
failure
(
String
message
)
{
ResponseModel
res
=
new
ResponseModel
();
res
.
setDevMessage
(
"FAILURE"
);
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setDevMessage
(
FAILURE
);
res
.
setMessage
(
message
);
res
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
return
res
;
}
public
static
ResponseModel
failure
(
Object
obj
,
String
message
)
public
static
ResponseModel
<
Object
>
failure
(
Object
obj
,
String
message
)
{
ResponseModel
res
=
new
ResponseModel
();
ResponseModel
<
Object
>
res
=
new
ResponseModel
<
Object
>
();
res
.
setResult
(
obj
);
res
.
setDevMessage
(
"FAILURE"
);
res
.
setDevMessage
(
FAILURE
);
res
.
setMessage
(
message
);
res
.
setStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
());
return
res
;
}
private
CommonResponseUtil
()
{
}
}
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