Commit 1cff153b authored by fupeiyang's avatar fupeiyang

消防专家接口修改

parent 67ba4802
......@@ -125,6 +125,7 @@ public class FireExpertsController extends BaseController {
FireExperts fireExperts = BeanDtoVoUtils.convert(fireExpertsDto, FireExperts.class);
Page<FireExperts> pageBean;
QueryWrapper<FireExperts> fireExpertsQueryWrapper = new QueryWrapper<>();
fireExpertsQueryWrapper.eq("is_delete", false);
Class<? extends FireExperts> aClass = fireExperts.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
......@@ -171,7 +172,7 @@ public class FireExpertsController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<FireExpertsDto>> selectForList() {
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList();
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
fireExpertsDtoList.stream().map(item -> {
item.setAge(BeanDtoVoUtils.getAge(item.getBirthdayTime()));
return item;
......
......@@ -7,28 +7,32 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.FireExpertsMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireExpertsService;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
/**
* 服务实现类
*消防专家
* @author system_generator
* @date 2021-06-25
*/
* 服务实现类
* 消防专家
*
* @author system_generator
* @date 2021-06-25
*/
@Service
public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExperts,FireExpertsMapper> implements IFireExpertsService {
/**
* 分页查询
*/
public Page<FireExpertsDto> queryForFireExpertsPage(Page<FireExpertsDto> page) {
return this.queryForPage(page, null, false);
}
public class FireExpertsServiceImpl extends BaseService<FireExpertsDto, FireExperts, FireExpertsMapper> implements IFireExpertsService {
/**
* 分页查询
*/
public Page<FireExpertsDto> queryForFireExpertsPage(Page<FireExpertsDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<FireExpertsDto> queryForFireExpertsList() {
return this.queryForList("" , false);
}
/**
* 列表查询 示例
*/
public List<FireExpertsDto> queryForFireExpertsList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("", false, isDelete);
}
}
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jcs.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;
......@@ -110,35 +111,24 @@ public class BeanDtoVoUtils {
}
});
}
//由出生日期获得年龄
// 根据LocalDate来计算年龄
public static int getAge(Date birthDay) {
if(birthDay == null){
if (birthDay == null) {
return 0;
}
LocalDate now = LocalDate.now();
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
throw new IllegalArgumentException("出生日期小于当前时间,无效的日期!");
}
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int monthBirth = cal.get(Calendar.MONTH) + 1;
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) age--;
} else {
age--;
}
LocalDate birth = LocalDate.of(yearBirth, monthBirth, dayOfMonthBirth);
if (birth.isAfter(now)) {
return 0;
}
int age = birth.until(now).getYears();
return age;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment