healthbody
This commit is contained in:
parent
f00653630b
commit
c58ecd61b8
|
|
@ -0,0 +1,85 @@
|
|||
package com.bonus.canteen.core.common.page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bonus.canteen.core.common.utils.JacksonUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class QueryParseHelper {
|
||||
private static final Logger log = LoggerFactory.getLogger(QueryParseHelper.class);
|
||||
|
||||
public static PageDTO getPageFromContent(String content) {
|
||||
PageDTO page = getPageOrNullFromContent(content);
|
||||
return page == null ? new PageDTO() : page;
|
||||
}
|
||||
|
||||
public static PageDTO getPageOrNullFromContent(String content) {
|
||||
PageDTO page = null;
|
||||
JsonNode jsonNode = JacksonUtil.readTree(content);
|
||||
if (jsonNode != null) {
|
||||
page = (PageDTO)JacksonUtil.treeToValue(jsonNode.path("page"), PageDTO.class);
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public static <T> Page<T> getPageFromContent(String content, Class<T> clz) {
|
||||
Page<T> page = new Page(1L, 10L);
|
||||
JsonNode jsonNode = JacksonUtil.readTree(content);
|
||||
if (jsonNode != null) {
|
||||
page.setCurrent(jsonNode.path("page").path("current").asLong(1L));
|
||||
page.setSize(jsonNode.path("page").path("size").asLong(10L));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <T> T getParamFromContent(String content, Class<T> clz) {
|
||||
T paramDto = null;
|
||||
|
||||
try {
|
||||
JsonNode jsonNode = JacksonUtil.readTree(content);
|
||||
if (jsonNode != null) {
|
||||
JsonNode object = jsonNode.get("object");
|
||||
paramDto = JacksonUtil.treeToValue(object, clz);
|
||||
}
|
||||
|
||||
if (paramDto == null) {
|
||||
paramDto = clz.newInstance();
|
||||
}
|
||||
} catch (IllegalAccessException | InstantiationException var5) {
|
||||
log.error("实例化对象失败", var5);
|
||||
}
|
||||
|
||||
return paramDto;
|
||||
}
|
||||
|
||||
public static <T> T getParamFromContentOrNull(String content, Class<T> clz) {
|
||||
T paramDto = null;
|
||||
JsonNode jsonNode = JacksonUtil.readTree(content);
|
||||
if (jsonNode != null) {
|
||||
JsonNode object = jsonNode.get("object");
|
||||
paramDto = JacksonUtil.treeToValue(object, clz);
|
||||
}
|
||||
|
||||
return paramDto;
|
||||
}
|
||||
|
||||
public static JsonNode getNodeFromContent(String content, String expression) {
|
||||
JsonNode node = JacksonUtil.readTreeOrMissing(content);
|
||||
return JacksonUtil.getByPath(node, expression);
|
||||
}
|
||||
|
||||
public static <T> T getValueFromContent(String content, String expression, Class<T> clz) {
|
||||
JsonNode node = JacksonUtil.readTreeOrMissing(content);
|
||||
JsonNode nodeByPath = JacksonUtil.getByPath(node, expression);
|
||||
return JacksonUtil.treeToValue(nodeByPath, clz);
|
||||
}
|
||||
|
||||
public static <T> T getValueFromContent(String content, String expression, T defaultValue) {
|
||||
return JacksonUtil.getValueByPath(content, expression, defaultValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.bonus.canteen.core.nutrition.common.dto;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.PageDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("慢性病查询入参")
|
||||
public class HealthChronicDto extends PageDTO {
|
||||
@ApiModelProperty("慢性病名称")
|
||||
private String chronicName;
|
||||
|
||||
public HealthChronicDto() {
|
||||
}
|
||||
|
||||
public static HealthChronicDtoBuilder builder() {
|
||||
return new HealthChronicDtoBuilder();
|
||||
}
|
||||
|
||||
public String getChronicName() {
|
||||
return this.chronicName;
|
||||
}
|
||||
|
||||
public void setChronicName(final String chronicName) {
|
||||
this.chronicName = chronicName;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "HealthChronicDto(chronicName=" + this.getChronicName() + ")";
|
||||
}
|
||||
|
||||
public HealthChronicDto(final String chronicName) {
|
||||
this.chronicName = chronicName;
|
||||
}
|
||||
|
||||
public static class HealthChronicDtoBuilder {
|
||||
private String chronicName;
|
||||
|
||||
HealthChronicDtoBuilder() {
|
||||
}
|
||||
|
||||
public HealthChronicDtoBuilder chronicName(final String chronicName) {
|
||||
this.chronicName = chronicName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HealthChronicDto build() {
|
||||
return new HealthChronicDto(this.chronicName);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "HealthChronicDto.HealthChronicDtoBuilder(chronicName=" + this.chronicName + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,15 +2,17 @@ package com.bonus.canteen.core.nutrition.common.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.canteen.core.nutrition.common.dto.HealthChronicDto;
|
||||
import com.bonus.canteen.core.nutrition.common.model.HealthChronic;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthChronicVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HealthChronicService extends IService<HealthChronic> {
|
||||
// PageVO<HealthChronicWithDetailVo> pageHealthChronic(Page<HealthChronic> page, HealthChronicDto content);
|
||||
//
|
||||
// List<HealthChronicVo> dictHealthChronic(HealthChronicDto content);
|
||||
//
|
||||
List<HealthChronicVo> dictHealthChronic(HealthChronicDto content);
|
||||
|
||||
// void addHealthChronic(HealthChronicWithDishesDto chronicWithDishesDto);
|
||||
//
|
||||
// void updateHealthChronic(HealthChronicWithDishesDto chronicWithDishesDto);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,13 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.canteen.core.nutrition.common.dto.HealthChronicDto;
|
||||
import com.bonus.canteen.core.nutrition.common.mapper.HealthChronicMapper;
|
||||
import com.bonus.canteen.core.nutrition.common.model.HealthChronic;
|
||||
import com.bonus.canteen.core.nutrition.common.service.HealthChronicService;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthChronicVo;
|
||||
import com.bonus.common.houqin.constant.DelFlagEnum;
|
||||
import com.bonus.common.houqin.utils.LeBeanUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
|
@ -62,13 +66,16 @@ public class HealthChronicServiceImpl extends ServiceImpl<HealthChronicMapper, H
|
|||
//
|
||||
// return PageVO.of((Page)page, healthChronicWithDetailVos);
|
||||
// }
|
||||
//
|
||||
// public List<HealthChronicVo> dictHealthChronic(HealthChronicDto content) {
|
||||
// LambdaQueryWrapper<HealthChronic> queryWrapper = (LambdaQueryWrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(HealthChronic.class).eq(StrUtil.isNotBlank(content.getChronicName()), HealthChronic::getChronicName, content.getChronicName())).eq(HealthChronic::getIfDel, DelFlagEnum.DEL_FALSE.key())).orderByDesc(HealthChronic::getCrtime);
|
||||
// List<HealthChronic> list = this.list(queryWrapper);
|
||||
// return LeBeanUtil.copyCreateList(list, HealthChronicVo.class);
|
||||
// }
|
||||
//
|
||||
|
||||
public List<HealthChronicVo> dictHealthChronic(HealthChronicDto content) {
|
||||
LambdaQueryWrapper<HealthChronic> queryWrapper = Wrappers.lambdaQuery(HealthChronic.class)
|
||||
.eq(StrUtil.isNotBlank(content.getChronicName()), HealthChronic::getChronicName, content.getChronicName())
|
||||
.eq(HealthChronic::getIfDel, DelFlagEnum.DEL_FALSE.key())
|
||||
.orderByDesc(HealthChronic::getCrtime);
|
||||
List<HealthChronic> list = this.list(queryWrapper);
|
||||
return LeBeanUtil.copyCreateList(list, HealthChronicVo.class);
|
||||
}
|
||||
|
||||
// @Transactional(
|
||||
// rollbackFor = {Exception.class}
|
||||
// )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package com.bonus.canteen.core.nutrition.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("慢性病基础表")
|
||||
public class HealthChronicVo {
|
||||
@ApiModelProperty("慢性病id")
|
||||
private Long chronicId;
|
||||
@ApiModelProperty("慢性病名称")
|
||||
private String chronicName;
|
||||
|
||||
public HealthChronicVo() {
|
||||
}
|
||||
|
||||
public static HealthChronicVoBuilder builder() {
|
||||
return new HealthChronicVoBuilder();
|
||||
}
|
||||
|
||||
public Long getChronicId() {
|
||||
return this.chronicId;
|
||||
}
|
||||
|
||||
public String getChronicName() {
|
||||
return this.chronicName;
|
||||
}
|
||||
|
||||
public void setChronicId(final Long chronicId) {
|
||||
this.chronicId = chronicId;
|
||||
}
|
||||
|
||||
public void setChronicName(final String chronicName) {
|
||||
this.chronicName = chronicName;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getChronicId();
|
||||
return "HealthChronicVo(chronicId=" + var10000 + ", chronicName=" + this.getChronicName() + ")";
|
||||
}
|
||||
|
||||
public HealthChronicVo(final Long chronicId, final String chronicName) {
|
||||
this.chronicId = chronicId;
|
||||
this.chronicName = chronicName;
|
||||
}
|
||||
|
||||
public static class HealthChronicVoBuilder {
|
||||
private Long chronicId;
|
||||
private String chronicName;
|
||||
|
||||
HealthChronicVoBuilder() {
|
||||
}
|
||||
|
||||
public HealthChronicVoBuilder chronicId(final Long chronicId) {
|
||||
this.chronicId = chronicId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HealthChronicVoBuilder chronicName(final String chronicName) {
|
||||
this.chronicName = chronicName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HealthChronicVo build() {
|
||||
return new HealthChronicVo(this.chronicId, this.chronicName);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "HealthChronicVo.HealthChronicVoBuilder(chronicId=" + this.chronicId + ", chronicName=" + this.chronicName + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.canteen.core.nutrition.mobile.controller;
|
||||
|
||||
import com.bonus.canteen.core.common.page.QueryParseHelper;
|
||||
import com.bonus.canteen.core.nutrition.common.dto.HealthChronicDto;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthChronicVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.canteen.core.nutrition.common.service.HealthChronicService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/health/mobile/chronic"})
|
||||
@Api(
|
||||
tags = {"mobile-移动端慢性病"}
|
||||
)
|
||||
public class HealthMobileChronicController {
|
||||
@Autowired
|
||||
private HealthChronicService healthChronicService;
|
||||
|
||||
@ApiOperation("获取慢性病字典")
|
||||
@GetMapping({"/dict-health-chronic"})
|
||||
public AjaxResult dictHealthChronic(String content) {
|
||||
HealthChronicDto paramFromContent = (HealthChronicDto) QueryParseHelper.getParamFromContent(content, HealthChronicDto.class);
|
||||
List<HealthChronicVo> list = this.healthChronicService.dictHealthChronic(paramFromContent);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue