Commit 1cff153b authored by fupeiyang's avatar fupeiyang

消防专家接口修改

parent 67ba4802
...@@ -125,6 +125,7 @@ public class FireExpertsController extends BaseController { ...@@ -125,6 +125,7 @@ public class FireExpertsController extends BaseController {
FireExperts fireExperts = BeanDtoVoUtils.convert(fireExpertsDto, FireExperts.class); FireExperts fireExperts = BeanDtoVoUtils.convert(fireExpertsDto, FireExperts.class);
Page<FireExperts> pageBean; Page<FireExperts> pageBean;
QueryWrapper<FireExperts> fireExpertsQueryWrapper = new QueryWrapper<>(); QueryWrapper<FireExperts> fireExpertsQueryWrapper = new QueryWrapper<>();
fireExpertsQueryWrapper.eq("is_delete", false);
Class<? extends FireExperts> aClass = fireExperts.getClass(); Class<? extends FireExperts> aClass = fireExperts.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> { Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try { try {
...@@ -171,7 +172,7 @@ public class FireExpertsController extends BaseController { ...@@ -171,7 +172,7 @@ public class FireExpertsController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询") @ApiOperation(httpMethod = "GET", value = "列表全部数据查询", notes = "列表全部数据查询")
@GetMapping(value = "/list") @GetMapping(value = "/list")
public ResponseModel<List<FireExpertsDto>> selectForList() { public ResponseModel<List<FireExpertsDto>> selectForList() {
List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(); List<FireExpertsDto> fireExpertsDtoList = fireExpertsServiceImpl.queryForFireExpertsList(false);
fireExpertsDtoList.stream().map(item -> { fireExpertsDtoList.stream().map(item -> {
item.setAge(BeanDtoVoUtils.getAge(item.getBirthdayTime())); item.setAge(BeanDtoVoUtils.getAge(item.getBirthdayTime()));
return item; return item;
......
...@@ -7,17 +7,21 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.FireExpertsMapper; ...@@ -7,17 +7,21 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.FireExpertsMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IFireExpertsService; import com.yeejoin.amos.boot.module.jcs.api.service.IFireExpertsService;
import org.springframework.stereotype.Service; 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 org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List; import java.util.List;
/** /**
* 服务实现类 * 服务实现类
*消防专家 * 消防专家
* @author system_generator *
* @date 2021-06-25 * @author system_generator
*/ * @date 2021-06-25
*/
@Service @Service
public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExperts,FireExpertsMapper> implements IFireExpertsService { public class FireExpertsServiceImpl extends BaseService<FireExpertsDto, FireExperts, FireExpertsMapper> implements IFireExpertsService {
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -28,7 +32,7 @@ public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExper ...@@ -28,7 +32,7 @@ public class FireExpertsServiceImpl extends BaseService<FireExpertsDto,FireExper
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
public List<FireExpertsDto> queryForFireExpertsList() { public List<FireExpertsDto> queryForFireExpertsList(@Condition(Operator.eq) Boolean isDelete) {
return this.queryForList("" , false); return this.queryForList("", false, isDelete);
} }
} }
...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.FireExperts; ...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.FireExperts;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -111,34 +112,23 @@ public class BeanDtoVoUtils { ...@@ -111,34 +112,23 @@ public class BeanDtoVoUtils {
}); });
} }
//由出生日期获得年龄 // 根据LocalDate来计算年龄
public static int getAge(Date birthDay) { public static int getAge(Date birthDay) {
if(birthDay == null){ if (birthDay == null) {
return 0; return 0;
} }
LocalDate now = LocalDate.now();
Calendar cal = Calendar.getInstance(); 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); cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR); 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 dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth; LocalDate birth = LocalDate.of(yearBirth, monthBirth, dayOfMonthBirth);
if (birth.isAfter(now)) {
if (monthNow <= monthBirth) { return 0;
if (monthNow == monthBirth) {
if (dayOfMonthNow < dayOfMonthBirth) age--;
} else {
age--;
}
} }
int age = birth.until(now).getYears();
return age; 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